[comp.sys.hp] POSIX orphaned process groups: automatic SIGCONT

tml@tik.vtt.fi (Tor Lillqvist) (02/18/91)

I earlier posted a question concerning a problem I had on HP-UX 7.0
with POSIX sessions and signals: A process (A) creates a new session
and process group by calling setsid(), forks, then the parent process
(A) exits and the child (B) forks (and execs new programs) a couple of
times.  Now I stop one of these new child processes (C), but as soon
as another child process (D) exits, the stopped process (C) magically
continues.

The (A) process (the process group leader) forks after setsid() so
that it won't by accident acquire a new controlling terminal.

Quotes from the HP-UX manual pages:

exit(2):
	If the exit of the calling process causes a process group to
	become orphaned, and if any member of the newly-orphaned
	process group is stopped, all processes in the newly-orphaned
	process group are sent SIGHUP and SIGCONT signals.

glossary(9): (This entry is only in the printed manual!)
	orphaned process group:  A process group in which the parent
	of every member is either itself a member of the group or is
	not a member of the group's session.

According to the reply I got, HP-UX checks in exit() if the process
belonged to an orphaned process group, and sends the SIGHUP and
SIGCONT signals, *even if it wasn't this exit that caused the process
group to become orphaned*.

So, I got around my problem by not exiting in (A), instead only waiting for
(B) to finish.  Additionally, (B) calls setpgid(0,0) so that it and
the children will be in their own, non-orphan, process group.  (It is
not an orphan process group because the parent of (B) is in another
process group in *the same session*.)

Whew... well at least now I think I understand the POSIX session and
process group concepts.
--
Tor Lillqvist,
working, but not speaking, for the Technical Research Centre of Finland