in reply to Backgrounding a Program

On Unix systems you can use this:

use POSIX; sub daemon { if($pid = fork) { # Parent exit 0; } elsif (defined $pid) { # Child setsid(); # detach session do_stuff(); # do some usefull stuff } else { die "Cannot fork: $!\n"; } }

Replies are listed 'Best First'.
Re: Re: Backgrounding a Program
by rob_au (Abbot) on Nov 16, 2001 at 08:49 UTC
    Just a quick note, the usage of POSIX doesn't necessarily exclude Windows-based systems with Windows NT and 2000 being POSIX-compliant (although I should note, there were a couple of questions on some functions with Windows NT) - The usage of POSIX does however preclude Windows 9x, for which Win32::Process offers a better solution with regard to setting priority classes and process suspension and execution.

     

    Ooohhh, Rob no beer function well without!