Sleep is an executable that we can use to simulate a blocking process for the purposes of demonstrating how to handle child processes.
Here's our base case.
The execution pattern is going to occur in this way: zsh (interactive) -> bash (./parent.sh) -> bash (./child.sh) -> sleep
. Because both Bash processes performed an exec
without fork
, the bash (./parent.sh)
process will be replaced by Bash (./child.sh)
, which itself will be replaced by sleep
. This will mean that there are no child processes to manage except for the immediate child of sleep
. Upon sending SIGINT, the sleep
process will be terminated, and there will be no resource leak. No orphaned nor zombie processes.
./parent.sh
: