In The Linux Programming Interface:
SIGHUP is generated when a process group becomes orphaned.
In an interactive bash process,
$ ( sleep 123 &)
will first forks a subshell, and the subshell then forks to execute sleep 123 &
. The subshell exits immediately without waiting sleep 123
to finish because of &
. At that time,
-
is the
sleep
process orphaned? (I think yes, Figure 34.3) -
is SIGHUP sent to the
sleep
process because it becomes orphaned? (I guess it is, by the quote) -
why doesn't the
sleep
process terminate because SIGHUP is sent to it? (I am not sure)
Thanks.
I also have similar question when create a daemon process by first forking a child process and then the child process forking a grandchild and exiting immediately. The grandchild becomes orphaned and isn't SIGHUP sent to it, making it terminate?
Best Answer
From The Open Group Base Specifications Issue 7, 2018 edition, System Interfaces, under
_exit
: