This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
explain meaning of negative PIDs in waitpid [perl #127080]
authorLukas Mai <l.mai@web.de>
Fri, 1 Jan 2016 14:35:58 +0000 (15:35 +0100)
committerLukas Mai <l.mai@web.de>
Tue, 5 Jan 2016 11:26:24 +0000 (12:26 +0100)
pod/perlfunc.pod

index 72e62a5..d27806c 100644 (file)
@@ -9052,8 +9052,15 @@ X<waitpid>
 
 Waits for a particular child process to terminate and returns the pid of
 the deceased process, or C<-1> if there is no such child process.  On some
-systems, a value of 0 indicates that there are processes still running.
-The status is returned in C<$?> and C<${^CHILD_ERROR_NATIVE}>.  If you say
+systems, a return value of 0 indicates that there are processes still running.
+The status is returned in C<$?> and C<${^CHILD_ERROR_NATIVE}>.
+
+A PID of C<0> indicates to wait for any child process whose process group ID is
+equal to that of the current process.  A PID of less than C<-1> indicates to
+wait for any child process whose process group ID is equal to -PID.  A PID of
+C<-1> indicates to wait for any child process.
+
+If you say
 
     use POSIX ":sys_wait_h";
     #...
@@ -9061,7 +9068,8 @@ The status is returned in C<$?> and C<${^CHILD_ERROR_NATIVE}>.  If you say
         $kid = waitpid(-1, WNOHANG);
     } while $kid > 0;
 
-then you can do a non-blocking wait for all pending zombie processes.
+then you can do a non-blocking wait for all pending zombie processes (see
+L<POSIX/WAIT>).
 Non-blocking wait is available on machines supporting either the
 waitpid(2) or wait4(2) syscalls.  However, waiting for a particular
 pid with FLAGS of C<0> is implemented everywhere.  (Perl emulates the