Unix does work! (Was: Unix doesn't work !)

Juergen Wagner gandalf at csli.STANFORD.EDU
Sun Mar 26 07:52:31 AEST 1989


The pipe consists of two ends, accessible through two file descriptors.
When the child process is forked, there are two processes with access to
the writable end. When the child exits, there is still the parent process
left which could write to the pipe. Therefore, a read will hang rather than
indicate EOF.

TFM says:
     Read calls on an empty pipe (no buffered data) with only one
     end  (all  write file descriptors closed) returns an end-of-
     file.

I suggest that you close the unused fds in the parent process, and your
program should work.

-- 
Juergen Wagner		   			gandalf at csli.stanford.edu
						 wagner at arisia.xerox.com



More information about the Comp.unix.questions mailing list