exit() and wait()

CovartDL zarth at drutx.UUCP
Fri Apr 19 09:46:18 AEST 1985


Thanks for all the responses to my previous net news article.
My code contained the line:
      if((pid = fork()) == -1)
when I typed it in I got it wrong. Everyone caught that.

Also, the agrument to wait almost everyone caught.
was:
      while((wid == wait((unsigned int*)rtn_code)) != pid);
should be:
      while((wid == wait(&rtn_code)) != pid);

Several people expressed intreset into why I used a while statement.
This was done because if someone else invokes this procedure from another
procedure which forked of a child but didn't wait for it, that childs
termination could cause this wait to wake up.

Thanks again for all the help I have my program working fine now.
Posted this so others can benifiet too.

				Zarth Arn



More information about the Comp.lang.c mailing list