Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!oakhill!nddsun1!dover.sps.mot.com!mathys From: mathys@dover.sps.mot.com (Yves Mathys) Newsgroups: comp.sys.apollo Subject: RE> problem with pipe/fork Message-ID: <978@nddsun1.sps.mot.com> Date: 17 Apr 91 15:52:12 GMT Sender: root@nddsun1.sps.mot.com Reply-To: mathys@dover.sps.mot.com (Yves Mathys) Organization: Motorola, Inc., Semiconductor Systems Design Technology SPS Lines: 43 >> From: gaumondp@JSP.UMontreal.CA (Gaumond Pierre) >> Subject: Problem with pipe/fork >> The following program creates a pipe and generates two processes with fork. The >> parent reads data from standard input and writes it to the pipe. The child >> reads the pipe and writes data to the standard output. >> >> Quite simple. However, it doesn't work. >> >> The program reads all the data and everything is transfered (I have tried a >> small file as a redirection of input). The processes block after the last >> character is transfered to the standard output. The processes seem to wait for >> something... for what? EOF? >> >> I understood that the "fclose" on the write end of the pipe would generate an >> EOF status at the read end. Is it correct. Perhaps the problem is somewhere >> else... A good pratice is to close all unused pipe descriptors so the close statement can effectively close the file descriptor. Closing fdi[0] and fdi[1] respectively in the parent and child will fix your problem. /*parent */ close(fdi[0]) ; fp= fopen(...) ... /*child */ close(fdi[1]) ; ... Yves Mathys mathys@dover.sps.mot.com Motorola Inc (Arizona) -- /\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ Yves Mathys Motorola Inc/Sector CAD mathys@scad.sps.mot.com