Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.2 9/18/84; site brl-tgr.ARPA Path: utzoo!watmath!clyde!bonnie!akgua!gatech!seismo!brl-tgr!tgr!phil@RICE.ARPA From: phil@RICE.ARPA (William LeFebvre) Newsgroups: net.unix-wizards Subject: Re: am I in background? Message-ID: <3082@brl-tgr.ARPA> Date: Sun, 10-Nov-85 00:54:24 EST Article-I.D.: brl-tgr.3082 Posted: Sun Nov 10 00:54:24 1985 Date-Received: Tue, 12-Nov-85 04:17:26 EST Sender: news@brl-tgr.ARPA Lines: 42 (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 Universityor, for the daring: