This post is to demonstrate a condition in which the child process stuck in zombie state due to parent process not reaping it.
example program
andorid: example: child process stuck in zombie state due to parent process
software of testing device
LA.BF64.1.1-06510-8×94.0 with Android 5.0.0_r2(LRX21M) and Linux kernel 3.10.49.
hardware of testing device
Architecture arm-v8 cortex-53.
log of running this program
$ adb shell /data/child-process-zombie-due-to-parent 7859:7859, program is starting 7859:7859, parent process after fork 7861:7859, child process after fork 7861:7859, child process is ready to _exit(2)
code flow
analysis: why the child process stuck in zombie state
If a child process exits, its state will become zombie and waits for its parent process to reap it. However, if its parent process doesn’t reap it, then the state of this child process will stay in zombie state.
how to make child process leave zombie state
conclusion
The child process become zombie after termination. If its parent process is a service and doesn’t exit, then the parent process needs to waitpid to reap its child process.
Leave a comment