Search code examples
windowsperlcgibackgroundfork

How can I fork a background processes from a Perl CGI script on Windows?


I've had some trouble forking of processes from a Perl CGI script when running on Windows. The main issue seems to be that 'fork' is emulated when running on windows, and doesn't actually seem to create a new process (just another thread in the current one). This means that web servers (like IIS) which are waiting for the process to finish continue waiting until the 'background' process finishes.

Is there a way of forking off a background process from a CGI script under Windows? Even better, is there a single function I can call which will do this in a cross platform way?

(And just to make life extra difficult, I'd really like a good way to redirect the forked processes output to a file at the same time).


Solution

  • If you want to do this in a platform independent way, Proc::Background is probably the best way.