Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!uupsi!sunic!news.funet.fi!kannel!Hannu.Martikka From: Hannu.Martikka@lut.fi (Hannu Martikka) Newsgroups: comp.sys.apollo Subject: Re: Problem with pipe/fork Message-ID: Date: 17 Apr 91 09:47:21 GMT References: <1991Apr16.150907.2417@jsp.umontreal.ca> Sender: goodgulf@lut.fi (Hannu Martikka) Organization: Lappeenranta University of Technology, Finland Lines: 44 In-Reply-To: gaumondp@JSP.UMontreal.CA's message of 16 Apr 91 15:09:07 GMT Disclaimer: All my opions are mine. (usually) >>>>> On 16 Apr 91 15:09:07 GMT, gaumondp@JSP.UMontreal.CA (Gaumond Pierre) said: .> character is transfered to the standard output. The processes seem .> to wait for something... for what? EOF? I think you haveto close all other pipe ends too. (stdin/stdout) Here I have simple program in witch child does who and parent does sort ie. who | sort. -- clip ---------------------------------------------------------- #include #include main(argc,argv) int argc; char **argv; { int pid; int pipeline[2]; pipe (pipeline); if ((pid=fork())== -1) { perror("fork"); exit(1); } if (pid != 0) { /* father */ close(0); /* Haveto close stdin */ dup (pipeline[0]); execlp("sort","sort",0); } else { /* child */ close(1); /* Haveto close stdout */ dup(pipeline[1]); execlp("who","who",0); } } -- Regards from Goodi ______________________________________________________________________________ Internet: Hannu.Martikka@lut.fi / \ Bitnet : GOODGULF@FINFILES // \\ \-\-\-\-\-\-\ oh5lhh Hannu Martikka, Punkkerikatu /// \\\ | on 70cm 7C 36, 53850 Lappeenranta,SF /// | \\\______________|_________________________ Tel. 953-251446 | :) Lappeenranta University Of Technology | ------------------------------------------------------------------------------