Re: SSH hangs while restarting services

2014-11-05 Thread Denny Lin
On Tue, Nov 04, 2014 at 08:48:03AM +0800, Denny Lin wrote:
 Recently I've been trying to restart services remotely using SSH using a
 command instead of entering the shell:
 ssh host sudo service postgresql restart
 
 PostgreSQL is able to restart successfully, but SSH just hangs there
 instead of exiting. I've noticed that this seems to affect any command
 which spawns a child process which doesn't exit.
 
 Is there any way to get SSH terminate? Thanks.

Sorry, I accidentally deleted the replies in my mailbox, so I'll respond
here.

I've tried running sudo /bin/sh and exiting immediately. There isn't any
hang, so it shouldn't be a sudo bug. I see the same hang over SSH if I
fork a process without sudo.

Adding -f to ssh like Kevin suggested solved the problem. Thanks!

-- 
Denny Lin
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to freebsd-ports-unsubscr...@freebsd.org


Re: SSH hangs while restarting services

2014-11-04 Thread Francois Tigeot
Hi,

On Tue, Nov 04, 2014 at 08:48:03AM +0800, Denny Lin wrote:
 
 Recently I've been trying to restart services remotely using SSH using a
 command instead of entering the shell:
 ssh host sudo service postgresql restart
 
 PostgreSQL is able to restart successfully, but SSH just hangs there
 instead of exiting. I've noticed that this seems to affect any command
 which spawns a child process which doesn't exit.

Can you check if it's really ssh which hangs or sudo ?

I have just stumbled upon a sudo bug myself: the child process launched
by sudo-1.8.11 hangs in the manner you just described. The same command
launched by sudo-1.8.10 works fine.

Running sudo /bin/sh and quitting the new shell is enough to verify if
everything's fine or not.

-- 
Francois Tigeot
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to freebsd-ports-unsubscr...@freebsd.org


SSH hangs while restarting services

2014-11-03 Thread Denny Lin
Hi,

Recently I've been trying to restart services remotely using SSH using a
command instead of entering the shell:
ssh host sudo service postgresql restart

PostgreSQL is able to restart successfully, but SSH just hangs there
instead of exiting. I've noticed that this seems to affect any command
which spawns a child process which doesn't exit.

Is there any way to get SSH terminate? Thanks.

-- 
Denny Lin
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to freebsd-ports-unsubscr...@freebsd.org


Re: SSH hangs while restarting services

2014-11-03 Thread Kevin Oberman
On Mon, Nov 3, 2014 at 4:48 PM, Denny Lin dennyli...@hs.ntnu.edu.tw wrote:

 Hi,

 Recently I've been trying to restart services remotely using SSH using a
 command instead of entering the shell:
 ssh host sudo service postgresql restart

 PostgreSQL is able to restart successfully, but SSH just hangs there
 instead of exiting. I've noticed that this seems to affect any command
 which spawns a child process which doesn't exit.

 Is there any way to get SSH terminate? Thanks.

 --
 Denny Lin


Try ssh -f host sudo service postgresql restart. If a socket is open,
ssh will not exist and something in the startup is leaving something link
STDOUT open. Use of '-f'' should work around this issue. From ssh(1):
 -f  Requests ssh to go to background just before command execution.
 This is useful if ssh is going to ask for passwords or
 passphrases, but the user wants it in the background.  This
 implies -n.  The recommended way to start X11 programs at a
 remote site is with something like ssh -f host xterm.

 If the ExitOnForwardFailure configuration option is set to
“yes”,
 then a client started with -f will wait for all remote port
for‐
 wards to be successfully established before placing itself in
the
 background.
--
R. Kevin Oberman, Network Engineer, Retired
E-mail: rkober...@gmail.com
___
freebsd-ports@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/freebsd-ports
To unsubscribe, send any mail to freebsd-ports-unsubscr...@freebsd.org