in reply to Re: spawning Perl scripts
in thread spawning Perl scripts

fork() on Windows is emulated using threads, so I'm not sure this is the best solution in this situation (as the fork and exec idiom will not work).

One way to start a process asynchronously is to use system() with an initial argument of 1:

if ($^O eq "MSWin32") { system(1, "cmd_to_run arguments"); } else { # do fork and exec, or use system("cmd_to_run arguments &"); }
The system(1, ...) call works at least on OS/2 too, and is "documented" in perlport.

Replies are listed 'Best First'.
Re: Re: Re: spawning Perl scripts
by awkmonk (Monk) on Mar 31, 2003 at 10:29 UTC

    By George your right!

    I tried fork and exec, but it just waits for the long process using the win32 Apache. system(1,cmd_to_run) works fine as will system(nohup cmd_to_run &) for the unix version.

    I considered using a trigger file and a separate process, but I prefer a self contained set of scripts.

    I'm forever in your debt.