fork question

Barry Margolin barmar at think.com
Thu Feb 7 11:51:48 AEST 1991


In article <DAVIS.91Feb6142453 at pacific.mps.ohio-state.edu> davis at pacific.mps.ohio-state.edu  (John E. Davis) writes:
>As you can see, the program forks with the parent exiting returning the pid of
>the child process.  This is precisely what happens when I run it at the unix
>command line.  Now in my .login I have the line:
>set slinepid = `sline`
>which sets the variable `slinepid' to the pid of the child.  This variable
>gets set but my .login gets hung up here-- ie. it does not continue beyond
>this point; I have to ^C to kill it.
>
>What fundamental point am I missing here?  It seems to me that the .login is
>waiting for the child to exit as well.

The child process has to close its stdout.  The problem is that the shell
is reading the pipe until it gets an EOF, and that doesn't happen until all
the processes on the other end of the pipe have closed it.
--
Barry Margolin, Thinking Machines Corp.

barmar at think.com
{uunet,harvard}!think!barmar



More information about the Comp.unix.questions mailing list