use POSIX qw/setsid/; my $pid = fork(); die $! unless defined $pid; if($pid == 0) { die $! unless setsid(); } else { exit(); }