Re: while (wait(&status) != pid) and waitpid (pid, &status, 0)

From: Alex Fraser (me_at_privacy.net)
Date: 11/26/05


Date: Sat, 26 Nov 2005 19:17:32 -0000


"Alex Vinokur" <alexvn@x-privat.org> wrote in message
news:43888857$1_2@x-privat.org...
> Are 'while (wait(&status) != pid)' and 'waitpid (pid, &status, 0)' have
> the same behavior?

No. Ignoring errors, the wait() loop ends after the child specified by pid
terminates, and waitpid() returns after the child specified by pid
terminates. But the wait() loop may collect (and promptly throw away) the
statuses of some other children, whereas waitpid() will not.

Alex



Relevant Pages

  • RE: OT: fork(): parent or child should run first?
    ... > But ATM the signal handler calls waitpid() and stores the pid in a ... > The main loop at some time in the future walks through ...
    (Linux-Kernel)
  • Timed Unix process for CMUCL
    ... (multiple-value-bind (pid status) ... ;;; Stuff to run a lisp function as a unix process with a timeout. ... (setf child-timed-out nil)) ... terminates the process running the body ...
    (comp.lang.lisp)
  • Re: OT: fork(): parent or child should run first?
    ... >>> called waitpid() on it? ... > it is actually prepared for the pid to be reclaimed. ... child did some work or slept before it exited. ... > active to an inactive array in the signal handler. ...
    (Linux-Kernel)
  • Re: Response to Karen and to Willem on recursive proofs
    ... )> Technically, this method proves that *if* a loop terminates, it terminates ... You have to *prove* that a loop terminates as well, ... decreases but doesn't go below zero. ... The only induction you need is when you want to rigorously prove that this ...
    (comp.programming)
  • Re: Scope
    ... Zero is false so the loop is ... not executed, and terminates. ... If fetchrow_array had returned undef (i.e. a list containing one ... Foo: 'first' ...
    (perl.beginners)