in reply to Update on controlling long-running processes via CGI
regarding the creation of a a child process,- fork() for itself creates just a clone of the current process, it's useless without a subsequent exec(). So after the fork() you have two (almost) identical processes, both of'em just returning from fork(). The fork return value is then used to determine whether it's child or parent - in case of parent you do the exec() then which replaces the clone with whatever process you like:
if($pid = fork()) {
#...this is the parent
...
} elsif (defined $pid) {
# this is the child...
exec(<whatever executable>)
} else {
# error - the fork() didn't work
}
|