in reply to Re: How do I run an Infinite loop with a CGI?
in thread How do I run an Infinite loop with a CGI?

Starting a process from within the Web server environment should probably be done with system and not fork or exec. It's true that in many cases, calling system results in a fork, but it is likely to work in cases where the others do not.

If your "daemon" script is properly behaved, and returns usable exit codes, you can do something like this:
my $error = system("/usr/local/bin/my.daemon"); if ($error) { print "<I>Problem launching server. (Error code $error)</I>\n"; } else { print "<I>Server started.</I>\n"; }
Forking off a copy of the Web server run-time environment and all of its associated baggage is rather inefficient, since you'd likely use very little of this. Starting a new process means that your "daemon" script can begin with a clean slate, no open file handles, allocated memory, and such.