http://qs321.pair.com?node_id=432538


in reply to CGI and System

Wrap your head around this. It forks away from the cgi, detaches the child process and execs your command. If you're just running a perl script, you can replace the system call with a function you want to run in the background.

use strict; use POSIX 'setsid'; my $command = q{perl -e 'sleep 30'}; if (my $pid = fork) { exit; } elsif (defined $pid) { open STDIN, '/dev/null'; open STDOUT, '>/dev/null'; open STDERR, '>/dev/null'; setsid(); unless (exec $command) { die "Couldn't run process!"; } } else { die "Cannot fork: $!"; }