Path: utzoo!utgpu!jarvis.csri.toronto.edu!clyde.concordia.ca!rutgers!tut.cis.ohio-state.edu!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!ames!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: Problems using ptys in perl. Message-ID: <6989@jpl-devvax.JPL.NASA.GOV> Date: 5 Feb 90 23:04:40 GMT References: <2276@uvaarpa.virginia.edu> <7115@ogicse.ogc.edu> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 28 In article <7115@ogicse.ogc.edu> hakanson@ogicse.UUCP (Marion Hakanson) writes: : I haven't worked out the nitty-gritty details, but the behavior I have : seen can be described as the parent writing to a forked filehandle, : after which the parent sees both what it wrote to that filehandle as : well as what the child wrote to it. In other words, the data gets : duplicated, instead of being consumed by (just) the child. I'm not : sure that you are seeing the same thing, but it looks similar. : : My intuition tells me that the implementation of the stdio subsystem : is at fault here, but I have not examined any source code to confirm : that hypothesis. Larry, I must say that this is one issue that makes : me wish Perl used Unix file descriptors instead of C file pointers, : but I certainly don't blame you for wanting to avoid implementing : your own buffered I/O system. But it certainly would make forking : a little less painful. Note the disclaimer in the manual entry on fork: fork Does a fork() call. Returns the child pid to the parent process and 0 to the child process. Note: unflushed buffers remain unflushed in both processes, which means you may need to set $| to avoid duplicate output. The disclaimer should probably be propagated to other constructs that do fork as well, such as open(). Larry