Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monk,

In my CGI script I am trying to fork another process for running some task in background (windows perl/activeperl)with fork() system call but found that in windows it's not supported. While searching found this node http://www.perlmonks.org/?node_id=104656 ... but in CPAN I don't find any Win32::CreateProcess module. Can I go for using Win32::Console Or it's only meant for console application.

.

Is there any other way I can fork a process for running in background. Please suggest.

Thanks.

Replies are listed 'Best First'.
Re: forking daemon under windows
by Anonymous Monk on Nov 30, 2009 at 11:56 UTC
    Hi Monks,

    After searching little more ... I used perl threading but the problem is it's waiting for the thread to complete if I join() else if I detach() then I dont get the returned data.

    Is there any way ... I can start the thread, come back to do some other thing and then wait for the thread to end and do something else and completes.

    .
      It sounds like you want to poll your thread and not join it until it is joinable. Look into thread states, is_joinable() is probably what you seek.

      -- Time flies when you don't know what you're doing
        Hi,

        Thanks for the reply. I am facing a problem with threading. I am redirecting to a different page and then closing STDOUT, STDERR and calling the function in thread,detaching it...so that it kinda runs in background.

        But once I run the CGI script...nothing happens ... in process list I dont see any perl.exe process. perl process is exiting.

        Is it a bug? Or I am doing something wrong. Thanks