Well I know I'm confused.
Here is a test case that will show my problem. When this is run as a cgi script, the browser will wait until the child exits before finishing. If I comment out the two Spreadsheet modules it works perfectly and finishes without waiting on the child process.
use strict;
go();
sub go
{
$| = 1;
$SIG{CHLD} = 'IGNORE';
close STDIN;
my $pid = fork;
if (!defined($pid)) {
print "Content-type: text/plain\n\n";
print "Could not fork!\n";
exit;
} elsif ($pid) {
print "Content-type: text/plain\n\n";
print "PARENT = $$, KID = $pid\n" . localtime(time);
close STDERR;
close STDOUT;
close STDIN;
exit;
} else {
close STDIN;
close STDOUT;
close STDERR;
use Spreadsheet::ParseExcel;
use Spreadsheet::WriteExcel;
open(STDERR, ">test.err");
sleep(10);
open(OUT,">>test") or die();
print OUT "\nKID(me) = $$ " . localtime(time);
close OUT;
exit;
}
}
|