csh pgrp problem
Chris Torek
chris at mimsy.UUCP
Fri Aug 11 20:21:02 AEST 1989
In article <712 at skye.ed.ac.uk> richard at aiai.ed.ac.uk (Richard Tobin) writes:
>I believe I've found the problem, what I want to know is whether there's
>a simple fix ... the shell forks twice (once for cat and once for more).
>Each child sets its process group to the jobid, which is cat's process id.
>The first child sets the terminal process group to the same thing.
>However, there's nothing to guarantee that the first child sets the
>terminal process group before the second child starts running ...
>
>Presumably using vfork() forces things to happen in the right order.
This analysis is correct (congratulations: discovering this bug is
rather tricky---the POSIX folks noticed it eventually, but it took
quite a while).
The accepted solution is to set the terminal's process group k+1 times
when there are k children in a pipeline (or k times with the current
system): once in each child and once in the parent. Setting the pgroup
to whatever it is already is harmless, and this ensures that the pgroup
is set by the time it needs to be.
(Most of the mess would go away if process groups were allocated
by the system, rather than by user code. But it is too late for
POSIX.)
--
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain: chris at mimsy.umd.edu Path: uunet!mimsy!chris
More information about the Comp.unix.wizards
mailing list