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; } }