Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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).

like image 612
Matt Sheppard Avatar asked Sep 05 '08 13:09

Matt Sheppard


2 Answers

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

like image 112
Leon Timmermans Avatar answered Nov 14 '22 23:11

Leon Timmermans


Use Win32::Process->Create with DETACHED_PROCESS parameter

like image 22
aku Avatar answered Nov 14 '22 23:11

aku