asked 125k views
4 votes
When a child process exits before the parent process exits, which of the following is true?

1) the child process becomes defunct
2) the parent process becomes defunct
3) if the parent process does not handle SIGCHLD, the child process becomes a zombie

asked
User Vidal
by
8.2k points

1 Answer

4 votes

Final answer:

When a child process exits before the parent, if the SIGCHLD signal is not handled, the child becomes a zombie, which occurs to allow the parent to retrieve the child's exit status, but it can cause resource leakage if not addressed properly by the parent process.

Step-by-step explanation:

When a child process exits before the parent process, the third statement provided is what typically occurs: if the parent process does not handle SIGCHLD, the child process becomes a zombie. A zombie process or defunct process is what a child process becomes after it has completed execution but still has an entry in the process table; this happens because it is waiting for the parent process to read its exit status. This state allows the parent process to retrieve the child's exit status and resource usage information. If the parent process never calls wait() or handles the SIGCHLD signal to reap the child, the child remains in the zombie state, potentially leading to resource leakage. Modern operating systems eventually clean up zombie processes, but it is considered good practice for parent processes to properly handle child termination to maintain system health.

answered
User Richard Poirier
by
7.8k points
Welcome to Qamnty — a place to ask, share, and grow together. Join our community and get real answers from real people.