my $chld = fork(); # I wan't the CGI to end quickly die "Can't fork: $!\n" if(!definded $chld); exit(0) if $chld; # CGI ends here POSIX::setsid(); # start new session $chld = open(CHLD, "|-"); # this does another fork internally die "Can't fork: $!\n" if(!definded $chld); if($chld == 0) { # this does the same as ">/dev/null 2>&1" in shell close(STDOUT); open(STDOUT, ">/dev/null"); close(STDERR); open(STDERR, ">&STDOUT"); # avoid parsing of the arguments by shell, especially if $Trigger_Job # or $Captured_User_Name contain some dangerous stuff exec './processor.pl', '-j', $Trigger_Job, '-u', $Captured_User_Name; } select(CHLD); # make CHLD my default output $| = 1; # enable autoflushing print $Captured_Password; # output captured password close(CHLD); # wait for child to finish it's work