am I in background?
William LeFebvre
phil at RICE.ARPA
Sun Nov 10 15:54:24 AEST 1985
(Note: this discussion concerns only 4.2 BSD)
> I was wrong, but you misstate the correction. It has nothing to do
> with whether the shell has the control terminal open. It depends on
> whether the tty process group equals the process group of the process.
Quite right. I intentionally oversimplified the situation rather than
be precise (when will I learn?). The process only gets a TTIN when the
tty process group is not the same as this. If the login process has
exited (causing a VHANGUP to get "sent" to all the children), the
process doing the read never gets the chance to get a TTIN, since the
VHANGUP action turned off both read and write ability for that file
descriptor. Thus, he gets an EBADF.
> If you are ignoring or masking TTIN, you will get a real EOF however.
>From "/sys/sys/tty.c", function "ttread" (lines 1027--1041):
/*
* Hang process if it's in the background.
*/
#define bit(a) (1<<(a-1))
while (tp == u.u_ttyp && u.u_procp->p_pgrp != tp->t_pgrp) {
if ((u.u_procp->p_sigignore & bit(SIGTTIN)) ||
(u.u_procp->p_sigmask & bit(SIGTTIN)) ||
/*
(u.u_procp->p_flag&SDETACH) ||
*/
u.u_procp->p_flag&SVFORK)
return (EIO);
gsignal(u.u_procp->p_pgrp, SIGTTIN);
sleep((caddr_t)&lbolt, TTIPRI);
}
The read returns EIO, not end of file. A simple test program will
prove this to be correct. I leave that as an exercise to the reader.
William LeFebvre
Department of Computer Science
Rice University
<phil at Rice.arpa>
or, for the daring: <phil at Rice.edu>
More information about the Comp.unix.wizards
mailing list