CS FundamentalsModerateGATE CS · Amazon/Microsoft SDE MCQ
A parent forks 3 children that each call exit(0) immediately; the parent then sleeps for a minute without calling wait() and without handling SIGCHLD. During that minute, what are the children?
- A. Orphans adopted by init, which reaps them
- B. Three zombies, each still holding a process-table entry
- C. Fully removed at once, since exit() frees every trace of them
- D. Stopped processes that resume running when the parent wakes up
Correct answer: B. Three zombies, each still holding a process-table entry
A terminated child keeps its PID and exit status until the parent waits for it, so the 3 become zombies. They become orphans (and get reaped by init) only if the parent itself exits.
More Operating Systems questions
- Why is a test-and-test-and-set spinlock (spin on a plain read, and only try the atomic exchange when the lock looks free) usually faster…
- A lock-free stack pops with CAS(&top, old, old->next). Thread 1 reads top = A (A->next = B) and is delayed; thread 2 pops A, pops B, then…
- A low-priority task L holds a mutex. High-priority H blocks on it, and medium-priority M (which does not need the mutex) becomes ready…
- A semaphore S starts at 7. Over time 20 wait() and 15 signal() operations complete on it, in some order, with no process left blocked at…
- A Unix process opens a file, forks, and both parent and child each write 100 bytes to the inherited descriptor (no OAPPEND, no seeks), one…
- Which statement about the convoy effect is correct?