#snipped if (my $pid=fork()) { $|=; # Set auto-flush. print "Status: 302 Moved Temporarily\n"; print "Location: asynctest.pl?c=$pid\n\n"; close STDOUT; exit; } else { # We don't really need the PID file, but # daemonize() complains if you don't provide it, # despite the manpage saying it's optional. my $pidfile="/var/tmp/async$$.pid"; my @current_user=getpwuid($<); daemonize($current_user[2],$current_user[3],$pidfile); sleep(20); unlink($pidfile); # otherwise it doesn't go away exit; }