http://www.perlmonks.org?node_id=73088


in reply to Starting a new process (fork?)

Instead of relying on the shell background metacharacter like ColtsFoot does, you can use the perl fork function.
use CGI ':standard'; my $pid = fork; if ($pid == 0) { # we are the child close; # close all filehandles so server won't try to stay open exec 'backupprogram' or exit ; # transfer execution } elsif ($pid) { # we are the original process print header, start_html, 'Backup initiated. You can close this window at any time', end_html; } else { die "Fork failed: $!\n"; } # something went wrong
You could write that as:
fork==0 and exec 'backupprogram'; print header,start_html,'etc...'
But that wouldn't be as reliable.

Update: Remembered close behaviour wrongly, that line should read
close STDOUT; close STDERR; close STDIN;