in reply to Re: Re: Embedded redirection
in thread Embedded redirection

I don't know; I'd have to experiment. The server may be killing you. Someone else may have better information, but I would try ignoring some signals. I suspect the server would send a HUP in a case like this, but it might be more aggressive.
$SIG{HUP} = $SIG{INT} = $SIG{TERM} = 'IGNORE';
Since that makes it a bit harder to kill a run-away process, you might want to set a timeout so your script commits suicide after a reasonable amount of time.
$SIG{ALRM} = sub { die "$$ timed out" }; alarm 30;

Replies are listed 'Best First'.
Re: Re: Re: Re: Embedded redirection
by Anonymous Monk on Jan 13, 2001 at 06:44 UTC
    This code finally worked.
    my $result= new CGI; print $result->redirect("http://www.example.com"); close STDOUT; my $pid = fork; exit if $pid; die "fork: $!" unless defined $pid;
    However, is this the most efficient way of doing things? Is it going to clog the system up if the script is accessed very freqeuntly? Thanks.
      It won't have any measurable impact on your system. Remember, the total number of processes running remains the same. The parent exits just as it spawns the child. All you're changing is that the child continues working in the background while the parent exits gracefully, allowing the HTTP request to complete.