Hacker News new | ask | show | jobs
by tyingq 3295 days ago
Still missing the check for fork returning -1, which would make your waitpid() hang forever, as -1 waits on all p̶i̶d̶s̶,̶ ̶e̶v̶e̶n̶ ̶i̶n̶i̶t̶.̶ children.

Edit: less problematic than my original wrong guess, but still bad for a shell, which eventually supports multiple concurrent children.

1 comments

Wrong, waitpid(-1, ...) waits on all child processes of the current process, and would return -1 with errno set to ECHLD if there is no children.

The point about missing error checking still stands though!

Ah, yes, any child...thanks for the catch.