Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Wait for an output pipe? Message-ID: <9708@jpl-devvax.JPL.NASA.GOV> Date: 27 Sep 90 17:14:47 GMT References: Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Distribution: comp Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 33 In article sps@mcnc.org (Stephen Schaefer) writes: : Before reading a : lot of perl source code and seemingly irrelevant pieces of the manual, : (if a simple answer is in the man page, it ought to be mentioned under : open or wait, and it's not), I'd like someone to tell me: how do I : wait for the output pipe to finish? Welllllll... In the man page, under open, it says Explicitly closing any piped filehandle causes the parent process to wait for the child to finish, and returns the status value in $?. So you simply have to close the RDIST filehandle. : ...OK, I could collect the process ID from pipe open, but then how do I : wait for that process? Wait is not documented as taking an optional : argument. A wait without arguments at the end of the program has : behaved as a no-op. I'm running on VAX 4.3BSD, and we do have wait3, : although the installation script mutters at our lack of wait4 (wait4 : what? :-). Version 4.0 will have waitpid(), with two arguments. The pid to wait for, and special flags to do things like non-blocking. If your machine has either wait4 or waitpid, you can use the special flags; otherwise, you can only wait in blocking mode for a specific pid (Perl emulates this by doing normal waits and remember all the exit statuses for later reference, until it finds the pid you were waiting for. If you waitpid on something that exited earlier, it just uses the status it remembered from before.) Larry