in reply to Re: Socket question Help!
in thread Socket question Help!

Okay, I changed the code to read like:
sub REAP {
        print "reaping\n";
        #1 until (-1 == waitpid(-1, WNOHANG));
        #$SIG{CHLD} = \&REAP;
        waitpid(-1);
          return $?;
}


When I execute I get the following:
Not enough arguments for waitpid at ./server.pl line 89, near "1)" Execution of ./server.pl aborted due to compilation errors.

Replies are listed 'Best First'.
Re: Re: Re: Socket question Help!
by robartes (Priest) on Nov 17, 2002 at 23:42 UTC
    Yes, I should have stated that the code is untested. If you use waitpid(), you have to specify some flags, even if they are 0:
    waitpit(-1,0);
    Or, alternatively, just use wait:
    wait; # Yep, just like that :)
    Sorry about the mistake.

    CU
    Robartes-

      When you use waitpid, the first parm is the process id or -1 (if you just want to kill time). For the second parm: you can specify it as 0, then the call is locked; or as 1, and the call is not blocked.

      I tested that, if you give an odd number for the second parm, the call does not block; but it blocks on even number. I realized that it's a bit map, and the last bit specifies whether the call is blocked.
      Does anyone know whether the rest bits are used?