Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!apple!oliveb!amdahl!kucharsk From: kucharsk@uts.amdahl.com (William Kucharski) Newsgroups: comp.unix.questions Subject: Re: Unix doesn't work ! Summary: Close unused fd's first Message-ID: <102hQ07cq71010PFlGc@amdahl.uts.amdahl.com> Date: 25 Mar 89 05:37:30 GMT References: <407@retix.retix.COM> Reply-To: kucharsk@amdahl.uts.amdahl.com (William Kucharski) Distribution: usa Organization: Amdahl Coup, UTS Products Hen House Lines: 27 In article <407@retix.retix.COM> randy@retix.retix.com.UUCP (Miyazaki Randy) writes: >Why does the child read not terminate with a End of File indication ? >Bizzarely enough, the program hangs both under BSD 4.3 and >S5R3 (Interactive VP/IX 1.0.6). This seems to contradict any >documentation on pipes I have seen. > Although it's not mentioned in the man page, you should close the file descriptor you are _not_ using on your end of the pipe (i.e., if you are the parent, close pipefd[1]; if you're the child, close pipefd[0].) If you change your code from > len = read(pipefd[0], &buf, 1); to close(pipefd[1]); len = read(pipefd[0], &buf, 1); it does work... -- William Kucharski ARPA: kucharsk@uts.amdahl.com UUCP: ...!{ames,decwrl,sun,uunet}!amdahl!kucharsk Disclaimer: The opinions expressed above are my own, and may not agree with those of any other sentient being, not to mention those of my employer. So there.