Re: Suitable for PEAR: A PHP4 implementation of Pearl's IPC::Open3

From: Date: Sun, 25 Apr 2004 14:38:07 +0000
Subject: Re: Suitable for PEAR: A PHP4 implementation of Pearl's IPC::Open3
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-28339@lists.php.net to get a copy of this message
<ch@lathspell.de> wrote : > Hello > > I struggeled for several hours solving the problem to write a IPC::Open3 > function I knew from Perl which was capable to do a popen(), write on > its stdin and read both, stdout *and* stderr with arbitrary amount of > data and order of input/output. > > Looking at the result it's only ~100 lines of code but a newbie would > fail here or even worse it would work first but suddenly stop for > certain called programs or data >4kb... > > So I now wonder if this function would be welcomed to PEAR. > > bye, > > -christian- > > [background for those not knowing the problems of blocking pipes] > Pipes to programs are implemented in the kernel as normally 4kb big > buffers to which both programs are connected. fread e.g. is now a so- > called blocking system calls that simply stops until either the pipe is > closed by the remote end via fclose or if data is available. Sames goes > for fwrite which sleeps if the 4kb buffer is full until the other side > empties it. Imagine now one side tries to write 10kb to stdout and the > other side tries to read from stderr -> deadlock. > Using proc_open() and stream_select() one can work around this deadlock > but I found no example for reading stdout and stderr on the web. Interesting, can you show the code ? Bertrand Mansion Mamasam

« previous php.pear.dev (#28339) next »