am I in background?
Ron Natalie
ron at BRL.ARPA
Sat Nov 9 06:52:39 AEST 1985
Being in the background is in the frame of mind of the shell.
If the user is using a standard Bourne Shell, being in the
background also means that either the standard input was
redirected or the shell set it to /dev/null. On shells
with job control, all it does is switch the terminal process
group to something different than the running process. The
standard input is not touched. However if the standard input
is still the terminal, the user will read EOF whenever he tries
to read it, unless he is catching SIGTTIN. In this case, he
will get the TTIN singal when he tries to read the tty.
You'll have to remember that under job control, things can migrate
from foreground to background to foreground. All background means
is the shell is not waiting on process completion.
It seems your best bet is to use a combination of isatty() (to check
for redirection) and either checking for EOF or catching the TTIN
signal.
-Ron
More information about the Comp.unix.wizards
mailing list