Re: Getting unbuffered output from a subprocess

2001-06-14 Thread Doug MacEachern

On Tue, 27 Mar 2001, Andrew Ho wrote:

 Hello,
 
 So, when doing a CGI and needing to execute a subprocess with input based
 on user input, I always do a open()-fork()-exec() like so:
... 
 When using a mod_perl script, I use Apache::SubProcess and the above
 stuff still works. However, let's say the subprocess I kicked off takes a
 while to process, but prints status information in the meantime (for
 example, tagging a big CVS tree, or indexing textfiles, or whatnot). I
 want the user to see the information real-time (so I'd probably have
 local $| = 1 inside the if($pid) block above).
 
 This no longer works under Apache::SubProcess. Tt buffers up all the
 output and then sends it all at once. So my parent process reads in an
 unbuffered way, but the child exec() outputs all at once.

can you post a small test case using Apache::SubProcess?  that'll make it
easier to see whats going on.




Getting unbuffered output from a subprocess

2001-03-27 Thread Andrew Ho

Hello,

So, when doing a CGI and needing to execute a subprocess with input based
on user input, I always do a open()-fork()-exec() like so:

if(defined(my $pid = open(KID, '-|'))) {
if($pid) {
print while KID;
close KID;
} else {
%ENV = ( ... );
exec('/full/path/to/bin', @args);
}
}

When using a mod_perl script, I "use Apache::SubProcess" and the above
stuff still works. However, let's say the subprocess I kicked off takes a
while to process, but prints status information in the meantime (for
example, tagging a big CVS tree, or indexing textfiles, or whatnot). I
want the user to see the information "real-time" (so I'd probably have
local $| = 1 inside the if($pid) block above).

This no longer works under Apache::SubProcess. Tt buffers up all the
output and then sends it all at once. So my parent process reads in an
unbuffered way, but the child "exec()" outputs all at once.

Is there any way to remedy this situation?

Thanks in advance.

Humbly,

Andrew

--
Andrew Ho   http://www.tellme.com/   [EMAIL PROTECTED]
Engineer   [EMAIL PROTECTED]  Voice 650-930-9062
Tellme Networks, Inc.   1-800-555-TELLFax 650-930-9101
--