in reply to How do you tell the parent process to stop it's HTTP transfer, when it forks off a child process?

I use forking alot for intense SQL queries when the results of the queries doesnt matter to the user.

There are two ways to do the forking that Ive found that fixes your problem.

Method one: Fork with a location tag. Once the browsers receive the location tag they go away without waiting.

Example:

#!/usr/bin/perl # # do pre fork stuff here # if (fork) { # # Damn browser, go away! # print "Location: http://www.wherever.com/blah\n\n"; exit; } # # do post forking stuff here #

Method two: Disable buffering and then close STDOUT.

Example:

#!/usr/bin/perl # #disable buffering # $| = 1; # # prefork stuff # if (fork) { # # stuff to display to user. other processing that # the user needs to see, ect. # print "Content-type: text/html\n\n"; print "Done"; } # # Close STDOUT; # close STDOUT; # # work in the background #

Pete

insert into pete('red hair','green eyes','overinflated ego');

  • Comment on Re: (petethered) How do you tell the parent process to stop it's HTTP transfer, when it forks off a child process?
  • Select or Download Code

Replies are listed 'Best First'.
Re: Re: (petethered) How do you tell the parent process to stop it's HTTP transfer, when it forks off a child process?
by petethered (Pilgrim) on May 31, 2001 at 05:20 UTC
    DAMN, posted the above as anonymous by accident ;(

    Pete

    insert into pete('red hair','green eyes','overinflated ego');