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;

Replies are listed 'Best First'.
Re: Re: Starting a new process (fork?)
by suaveant (Parson) on Apr 17, 2001 at 17:51 UTC
    close; # close all filehandles so server won't try to stay open
    Not a big deal, bit this only closes the currently selected filehandle... which is usually STDIN, though I think that's all you need to close for the httpd to be happy.
                    - Ant