Parts
Code Examples
Interview Q&As
Chapter 26
Why This Chapter Matters
When a parent process creates children with fork(), it is responsible for monitoring them. Failing to do so causes zombie processes that pile up in the kernel process table and can eventually crash your system. This chapter covers every tool Linux provides for child process monitoring — from basic wait() to asynchronous SIGCHLD-driven reaping.
These concepts appear in almost every Linux interview for embedded, systems, and backend roles.
Series Parts
The fundamental child-reaping call. How it blocks, what it returns, and how to loop over all children. Includes the limitations that led to waitpid().
Selective waiting, non-blocking polls with WNOHANG, and detecting stopped children with WUNTRACED. The go-to call for most production code.
Decoding the 16-bit status integer using W* macros. How to detect normal exit, signal death, core dumps, stopped state, and continued state.
Advanced variants — waitid() with siginfo_t and WNOWAIT peek; wait3()/wait4() for resource usage. Includes a full comparison table.
What happens when parent or child dies first. Why zombies can’t be killed. Why zombie accumulation is dangerous. How init adopts orphans.
Asynchronous child monitoring. The correct SIGCHLD handler pattern, the signal queuing problem, errno preservation, SA_NOCLDSTOP, SIG_IGN, and the sigprocmask+sigsuspend race-condition fix.
Free Linux & Embedded Systems Tutorials
All tutorials on EmbeddedPathashala are completely free. No paywalls, no ads.
