I was reading about the
All of these system calls are used to wait for state changes in a child of the calling process, and obtain information about the child whose state has changed. A state change is considered to be: the child terminated; the child was stopped by a signal; or the child was resumed by a signal
wait() allows a process to wait until one of its child processes change its state, exists for example. If
waitpid() is called with a process id it waits for that specific child process to change its state, if a
pid is not specified, then it's equivalent to calling
wait() and it waits for any child process to change its state.
wait() function returns child pid on success, so when it's is called in a loop like this:
It means wait until all child processes exit (or change state) and no more child processes are unwaited-for (or until an error occurs)