Benjamin Scott writes:

>   However, most X programs seem to handle the situation you describe without
> trouble.  I'm not sure if this is because they deliberately set the SIGHUP
> signal to be ignored,

Not usually.  For example, send netscape a SIGHUP (it dies).

> or if they don't use terminal I/O and thus don't
> encounter the problem,

Getting warmer...

> or what, but I routinely open a terminal, issue
> "netscape &", and then close the terminal, without problems.

The key here seems to be that netscape (and a few other GUI programs
that I've looked at) become their own process group leaders.  I guess
they deliberately do this to solve exactly this problem (netscape
shouldn't die when the parent shell that invokes it dies).  But
netscape doesn't seem to disassociate itself from the controlling tty
(this seems to be sensible).

We can see this pretty clearly on my Solaris box:

: $ ps -jelf | awk 'l++<1 { print } /netscape/ {print}'
:  F S      UID   PID  PPID  PGID   SID  C PRI NI     ADDR     SZ    WCHAN    STIME 
:TTY      TIME CMD
:  8 S   kclark 25845  1101 25845  1101  0  50 20 60d328b0   2949 60c5571e 11:27:58 
:pts/5    0:04 netscape
                ^^^^^       ^^^^^

(PID 1101 is the bash shell that I invoked netscape from)               
                
PID  == process ID
PGID == process group ID
SID == PID of session leader

When a process' PGID equals its PID, then that process is the process
group leader.  Same sort of thing for session IDs.

Ergo, the above snippet shows that netscape is its own process group leader.

What does all of this have to do with the shell that you originally
ran "netscape &" from and then killed?  Well, that shell (PID=1101 in
my example above) was the process group leader of that particular
group, and when it dies the kernel sends the SIGHUP signal to the rest
of the processes in that process group.  But netscape isn't in the
shell's process group -- it deliberately disassociated itself from
that group and formed its own.

That's why netscape doesn't die when you kill the shell.

Regards,

--kevin
-- 
Kevin D. Clark          |                          |
[EMAIL PROTECTED] | [EMAIL PROTECTED] |  Give me a decent UNIX
Enterasys Networks      | PGP Key Available        | and I can move the world
Durham, N.H. (USA)      |                          |


**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to