in reply to semi-finite background process
I think what you might want to do is to do a fork in your CGI program. In the parent, just exit. In the child, you close STDIN, STDOUT, and STDERR, then exec your new process.
The key is that you close the open (shared) filehandles; this breaks the connection between the parent and child. Otherwise, the parent won't exit.
Here's some sample code:
my $pid = fork; die "Couldn't fork: $!" unless defined $pid; if ($pid) { # parent print "Forked off a child!"; exit; } else { # child close(STDIN); close(STDOUT); close(STDERR); exec "/foo/bar/long/process" or die "Can't exec: $!"; }
|
|---|