Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much

Re: Problem w/ forking CGI script

by almut (Canon)
on Oct 01, 2008 at 22:06 UTC ( #714909=note: print w/replies, xml ) Need Help??

in reply to Problem w/ forking CGI script

In my experience, you also need to close STDERR in the child (at least with recent Apaches), not only STDOUT.

Try adding

... } elsif (defined $pid) { # child does close STDOUT; # so parent can go on close STDERR; # <--- THIS ...

(The open STDERR, ">&=1"; which you find in merlyn's code doesn't implicitly close file descriptor number 2 (stderr) under the hood ... as you can verify using strace. )

The fact that it (seemingly) works with Safari probably has to do with different browser buffering behavior, i.e. it presumably processes partial content differently (before the HTTP request has completed). But that's just a guess — at the moment I don't have a Safari to investigate this further.  (You could check whether the individual Apache children (CGI processes) actually do terminate as expected in this case...)

Replies are listed 'Best First'.
Re^2: Problem w/ forking CGI script
by tlm (Prior) on Oct 03, 2008 at 16:20 UTC

    Thanks for the tip. That's good to know in general.

    The way I ultimately solved the problem was to examine the requests generated by both Safari and Firefox. One important difference was that Firefox was sending a "Keep-Alive: 300" header, while Safari wasn't. This gave me the idea of modifying the redirection to

    print redirect( -Location => self_url(), -Connection => 'close' );
    This worked.

    But your suggestion of closing STDERR also works. I'll do both from now on, for good measure. :-)

    the lowliest monk

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://714909]
[LanX]: nevermind
Tanktalus is at work, ssh'd home, using his cbstats bridge to talk on perlmonks CB. :)
[Tanktalus]: anyway, next is to figure out how to get postgres to agree that these are the same :)

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (14)
As of 2018-03-21 15:56 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (269 votes). Check out past polls.