in reply to wait problem for WIN32 perl

You don't seem to be saving the child pids anywhere so you can check to see if they have completed.

Why don't you take a look at Randal Schwartz's May 2002 Unix Review column. It has an example of doing exactly this.

Doing many things, like pings

Replies are listed 'Best First'.
Unix Review column
by kage-yojimbo (Initiate) on May 20, 2005 at 15:20 UTC
    Thanks for the suggestion. After much reading and analysis of the sample code I discovered that my WIN2000 servers are returning PIDs which are negative numbers. That threw a kink into processing which was designed to look for the "no more processes" flag.

      The negative pids aren't produced by win2k, but by Perl's fork emulation on win32 which uses -$tid as the (pseudo-) process id.

      This behaviour is documented in perlfork and if you page down to the bugs section, you'll see that the problem you encountered with wait is obliquely described there.

      It makes the correct way to wait for all subprocesses to terminate:

      1 while wait() != -1;

      This relies on the fact that the first thread of a process is 1, which means that no forked pseudo-process will have pid of -1 and should therefore work cross-platform.


      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      Lingua non convalesco, consenesco et abolesco. -- Rule 1 has a caveat! -- Who broke the cabal?
      "Science is about questioning the status quo. Questioning authority".
      The "good enough" maybe good enough for the now, and perfection maybe unobtainable, but that should not preclude us from striving for perfection, when time, circumstance or desire allow.