in reply to Managing a long running server side process using CGI

I don't know how the Windows folks spawn their child processes, but in *nix, it's fork. For example:

my $pid = fork(); if ( ! defined $pid ) { die "Can't fork: $!\n"; } if ( $pid ) { # parent } else { # child }

You could also look at Proc::Daemon which has this and more wrapped up in a tidy package.

Using a file to do your communication is a fine idea. To avoid polling, you could also use signals to let the worker know when to look. Have a look at the "Signals" section of perlipc.

Replies are listed 'Best First'.
Re^2: Managing a long running server side process using CGI
by xdg (Monsignor) on Jan 27, 2007 at 16:25 UTC
    I don't know how the Windows folks spawn their child processes

    Win32::Job provides a high-level interface for controlling sub-processes. More low-level is Win32::Process. And there is also system(1, $program, @args) for something that is more akin to a fork/exec on unix.

    -xdg

    Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.