Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!uunet!mcsun!ukc!edcastle!aiai!richard From: richard@aiai.ed.ac.uk (Richard Tobin) Newsgroups: comp.unix.wizards Subject: Re: How do I get EOF from a pipe I created? Message-ID: <3142@skye.ed.ac.uk> Date: 7 Aug 90 13:42:43 GMT References: <6366.26be9bd9@csv.viccol.edu.au> Reply-To: richard@aiai.UUCP (Richard Tobin) Organization: AIAI, University of Edinburgh, Scotland Lines: 25 In article <6366.26be9bd9@csv.viccol.edu.au> timcc@csv.viccol.edu.au (Tim Cook) writes: > if (fork ()) { > /* Subprocess */ No, fork() returns non-zero in the parent, so you're having the parent rather than the child exec /dir/command. This is why you are returning to the shell and leaving the other process in the background. Try if(fork() == 0) instead. The other problem is that the process reading the pipe doesn't close the other (write) end. Read from a pipe returns eof if there is no process that could write more data. The parent should do this after the fork(): close(pipe_descriptors[1]); -- Richard -- Richard Tobin, JANET: R.Tobin@uk.ac.ed AI Applications Institute, ARPA: R.Tobin%uk.ac.ed@nsfnet-relay.ac.uk Edinburgh University. UUCP: ...!ukc!ed.ac.uk!R.Tobin