am I in background?
David W. Vezie
dv at well.UUCP
Wed Nov 13 12:56:46 AEST 1985
(diving into a discussion, head first)
In article <3072 at brl-tgr.ARPA> ron at BRL.ARPA (Ron Natalie) writes:
> ... It depends on
>whether the tty process group equals the process group of the process.
>This is the surefire way of checking for background status under csh
>and the Bourne shell in jobs mode.
Getting back to the original question, if you are running 4.2 BSD,
you can use the getpgrp() function along with the ioctl (TIOCGPGRP)
ioctl, and compare the two values. Csh, (and probably jobs mode in
Bourne shell, although I can't speak for that), sets the terminal
process group (obtained by TIOCGPGRP) to whatever process is currently
in the foreground (be it the shell or whatever). The only difference
between "cmd" and "cmd &" is that with "cmd", the terminal process group
is set to the process group of "cmd" (or "cmd | othercmd").
--
David W. Vezie /!well!dv - Whole Earth 'Lectronics Link, Sausalito, CA
{dual|hplabs}
(4 lines, 166 chars) \!unicom!dave - College of Marin, Kentfield, CA
More information about the Comp.unix.wizards
mailing list