|Keep It Simple, Stupid|
Problem w/ forking CGI scriptby tlm (Prior)
|on Oct 01, 2008 at 19:47 UTC||Need Help??|
tlm has asked for the wisdom of the Perl Monks concerning the following question:
I'm trying to debug some legacy CGI code that is not working right with some web browsers, notably Firefox. The strategy this script uses is pretty much the same one that merlyn illustrates with a simple script in one of his Linux Magazine columns:
This script is supposed to execute a long-running command and display updates along the way. It does this by forking the original process so that the child continues on to feed data to a cache, while the parent essentially instructs the browser to check back periodically for updates.
I've installed merlyn's script locally, and it works fine when I access it with Safari, but it does not behave properly when I use Firefox: instead of displaying the updates, it only displays the final output.
The reason behind this hunch is that, if I watch the Apache access logs while I attempt to run the script, I see only two lines corresponding to this interaction: the initial POST and the very last GET; all the intervening GETs are missing (and there's nothing in the error log). More importantly, the initial POST does not appear in the logs when it is made, but several seconds later, simultaneously with the appearance of the final GET line, right around the time when the browser finally displays the results. This suggested to me that maybe the initial POST was not being deemed complete until the child from the initial fork was done.
Even if this is the case, it's not entirely clear to me why the behavior is different with Safari. (When the interaction is with Safari, all the intermediate GETs show up in the logs, and they appear at regular intervals throughout the interaction.)
If anyone has any ideas about how to troubleshoot this further please let me know.
Many thanks in advance!
the lowliest monk