in reply to Re: CGI, fork, long processes on Apache 2
in thread CGI, fork, long processes on Apache 2

The code you provided isn't very helpful. Are you saying that the script itself fails, or that the script works in the background, and the web page won't refresh? There is a big difference, and there are very different answers to each question.

print $query->redirect("New URL goes here");

The script doesn't fail, it's the redirect header that's not being honored by the browser because Apache hasn't dropped the connection. The redirect will go through once the process ends (a good three or four minutes later.) To shortcut that wait, I fork and the parent dies.

Now that I've re-read your post a couple of times, I like that you presented a viable alternative to my redirect/fork trick. Why not print a page to the browser asking it to refresh itself to the page I want? That's so simple and obvious compared to redirect/fork. I'll try it and post back when it works.

Thanks as well for the Javascript update % idea. I wasn't aware that Javascript could reach out to the web and read in another page outside the current one. Javascript gives me the willies though because of how difficult it is to make a script work in every browser. Maybe I'll take a look at it again in the near future.

  • Comment on Re: Re: CGI, fork, long processes on Apache 2

Replies are listed 'Best First'.
Re^2: CGI, fork, long processes on Apache 2
by Anonymous Monk on Apr 03, 2004 at 23:36 UTC

    I'm not really sure about this, but does your script close STDOUT and STDERR (and possibly repoen them to /dev/null) after the redirect is printed out? This will tell the browser to see a closed connection and it won't wait for anything more.

      There is a bug in Apache 2.0.x. If you have a long running CGI script you'll see an error in your CGI logs: The timeout specified has expired: ap_content_length_filter: apr_bucket_read() failed. This is why his script works properly under apache 1.3 and not 2.0.x -- because under Apache 2.0.x there comes a point where it just won't die.

      Want to support the EFF and FSF by buying cool stuff? Click here.