57.4k views
2 votes
Consider a parent process P that has forked a child process C. What happens when C exits while P is waiting for an I/O operation?

User Rkyr
by
7.9k points

1 Answer

3 votes

Final answer:

When the child process exits while the parent process is waiting for I/O operation, the behavior depends on whether the wait system call is blocking or non-blocking.

Step-by-step explanation:

When the child process C exits while the parent process P is waiting for an I/O operation, the behavior depends on whether the wait system call is blocking or non-blocking.

If the wait system call is blocking, the parent process P will be suspended until the child process C exits. Once C exits, the wait system call will return and the parent process P can continue with its next instructions.

On the other hand, if the wait system call is non-blocking, P will immediately continue with its next instructions, even if C has not exited yet. In this case, the status of C can be checked later using appropriate system calls.

User Geert Bellekens
by
8.4k points