setpgrp() affecting TTY GROUP ID
Alan Fargusson
alan at drivax.UUCP
Sun Sep 29 13:52:22 AEST 1985
> I am using setpgrp() (in a shell that I am writing) to change the PROCESS
> GROUP ID of the child after the first fork(). This allows me to use kill()
> to send signals to that child and all of its children (because they
> share the same PROCESS GROUP ID).
>
> However, it seems that certain programs which try to open the device
> "/dev/tty" don't work when setpgrp() has been called. Examples are
> "su" and a version of "mail" that I have.
>
> A symptom: a "ps" shows the TTY of each child to be "?".
> I can even type "ps -t\?" and get a list of these children.
>
> Nowhere in the documentation is it indicated that setpgrp() should have
> any effect on the controlling terminal for a process.
>
> Why is this happening?
>
> P.S.
> By removing the call to setpgrp() this problem disappears completely.
I know that the documetation is not clear on this, but the kernel uses
the process group to determine the controlling terminal. The result of
this is that changing the process group effectivly disconnects the process
from the controlling terminal. Some utilities like lpsched use setpgrp()
to prevent the terminal from sending them signals because they use signals
to decide when there is work to do.
--
Alan Fargusson.
{ ihnp4, amdahl, mot }!drivax!alan
More information about the Comp.unix.wizards
mailing list