in reply to Win32 fork() "problem"

I've never used them, but a perl book I read recently suggests Win32::Spawn or Win32::Process modules if Fork is being difficult (Fork is introduced experimentally on Win32 systems in Perl 5.6.1). The latter is more robust, more advanced but harder.

Replies are listed 'Best First'.
Re: Re: Win32 fork() "problem"
by maa (Pilgrim) on Mar 26, 2004 at 12:13 UTC

    Hi, dawn

    I've looked at those modules already and will probably end up utilising Win32::Job on an XP box at some point. This has the benefit of easily being able to set a timeout for a command using $job->run($cmd,$timeout) which is a huge improvement for Win32 platforms.

    I was really hoping I had made a glaring logic error (rather than fork() just playing up) in my use of fork...

    If I can't get a simple case like this to work (does this work on another platform?) I'll have to resort to a more brute force method of divvying up work. :-(

      FYI, your code works fine on Linux. Here is the output:
      Parent 962 got PID 963 from fork(962 Computer1) 963 Computer1 +Parent 962 got PID 964 from fork(962 Computer2) 964 Computer2 + 965 Computer3 Parent 962 got PID 965 from fork(962 Computer3) +Parent 962 got PID 966 from fork(962 ) 966 +wait() ed until -1 was returned.
      Another module that you might look into is IPC::Run. I know that it has at least some Win32 functionality.