Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re^2: Long CGI process is cut short by browser

by C_T (Scribe)
on Dec 07, 2004 at 00:37 UTC ( [id://412792]=note: print w/replies, xml ) Need Help??


in reply to Re: Long CGI process is cut short by browser
in thread Long CGI process is cut short by browser

This example by Randal helped me figure out how to keep the process alive.

Perhaps you guys can solve the other part of the equation. Right now I'm doing something like this:

#===== Open I/O pipes and run the process $pid = open3(\*DEV_NULL, \*OUT, \*ERR, "my_long_process"); #===== Print the results while (<OUT>) { $buffer .= $_; #===== Update the display cache $cache->set($session, [0, $buffer]); }

Which works, except it waits until my_long_process completes before it sends any output back to the browser. If my_long_process takes an hour to run, the browser sits there for an hour with no updated information.

Is there a way to set open3() to an unbuffered mode so it returns what my_long_process is doing in real time?

Failing that, is there a better way to do this long process in the fork such that I can get its results as its doing things rather than waiting until the end?

Thanks!

CT

Charles Thomas
Madison, WI

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://412792]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (5)
As of 2024-04-19 11:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found