[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-users] Apache/Perl/Fork Problem



Hello,

    I'm new to the list but not so new to unix, web servers and perl.  I've
written a script that could spend several minutes waiting for socket
responses so I've coded it to fork off and close STDOUT so the web request
will exit while the fork works in the background.  Fork works fine running
the script under the shell but through Apache it doesn't close the session
until the forked child dies.  Help?!  Below is a simple piece of code to
test what I'm explaining, try it via telnet and via the web and you'll see
what I mean.

Thanks in advance,
    Ed
-------------------------
#!/usr/bin/perl -w

use strict;

my $pid = fork();

if ($pid == 0) {
    close STDOUT;
    sleep 30;
    exit(0);
} else {
    print "Content-type: text/html\r\n\r\nHi there!";
    close STDOUT;
    exit(0);
}