Perl - CGI and Fork
I recently had the need to fork a child process from within a CGI application. After a few searches I came up with the following basic syntax which is based on a an article by Randal Schwartz.
# Forking a new child process to handle the ping attempts without the wait
defined(my $childpid = fork)
or eval{$self->_set_error('Could not fork ping processes.');
return; };
if ($childpid) {
# Parent process exits
return;
}
else {
# Child process runs it's course
Child process execution here....
exit; }