I know that one of the differences between wait() and waitpid() is that waitpid having a WNOHANG option which tells the waitpid not to block if there are running children that have not yet terminated. Such as:
while ( (pid = waitpid(-1, &stat, WNOHANG)) > 0)
printf("Child %d terminated\n", pid);
If I use wait() instead of waitpid(), there is no way to prevent wait() from blocking if there are running children that have not yet terminated. However, I wonder if wait() works fine here, even though it may block.