Article delegate-en/3388 of [1-5169] on the server localhost:119
  upper oldest olders older1 this newer1 newers latest
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]
Newsgroups: mail-lists.delegate-en

[DeleGate-En] Re: Detaching from terminal not good, SSH session hangs on logout
12 Jul 2006 11:03:06 GMT (Yutaka Sato)
The DeleGate Project


In message <_A3386@delegate-en.ML_> on 07/12/06(17:11:50)
you Steffen Kaiser <> wrote:
 |when I start the delegate demon from within a SSH session, the session 
 |hangs upon logout. Lately I came across the same problem for yet another 
 |program, too, and there the problem was addressed to "demonize properly", 
 |e.g. as described by:

Hmm...  Indeed since I recently started to use SSH to login to multiple
Linuxes (on a VirtualPC), I have suffered this problem.  But I didn't
notice that it is caused by DeleGate, and have become used to do
shutting down the SSH session with "~." each time :).

I coded the daemonizing of DeleGate on SunOS4 which is based on BSD (when
I hated SysV :), and recently living on MacOSX based on BSD, so I have not
been able to notice the problem.

 |The most important trick is to fork() twice, so the process becomes its 
 |own process group and is detached from any terminal and process group.

I think it is the very functionarity of setsid() and it works as expected
on BSD.  I tested to close the standard input after setsid() as the
enclosed patch, and it solved the problem of SSH on Linuxes I have
(Debian3.1 and RedHat9).

  9 9   Yutaka Sato <>
 ( ~ )  National Institute of Advanced Industrial Science and Technology
_<   >_ 1-1-4 Umezono, Tsukuba, Ibaraki, 305-8568 Japan
Do the more with the less -- B. Fuller

*** delegate9.2.3-pre12/src/delegated.c	Sun Jul  9 20:24:15 2006
--- delegated.c	Wed Jul 12 19:52:24 2006
*** 1777,1784 ****
--- 1777,1785 ----
  	if( !INHERENT_spawn() ){
  		if( Fork("daemon") != 0 )
+ 		dup2(open("/dev/null",0),0);
  	if( isService ){ /* it is running as a service */

  admin search upper oldest olders older1 this newer1 newers latest
[Top/Up] [oldest] - [Older+chunk] - [Newer+chunk] - [newest + Check]