Comment by PopGreene
9 hours ago
There's something I don't understand. In the trap line for the parent process, the variable "$child_pid" appears. How did that get set?
9 hours ago
There's something I don't understand. In the trap line for the parent process, the variable "$child_pid" appears. How did that get set?
Hey PopGreene, initially, `$child_pid` was set, but I refactored to use `$!` throughout instead. It must have been an oversight when I refactored `$child_pid` out, as the script still passes with the `$child_pid` not set. This is because running `wait` without an argument exits successfully. With `$child_pid` no longer set, it should be replaced with `$!`; otherwise, the script does not wait until the child process is terminated.
To clarify, the `wait` is there to avoid zombie processes, which is the script's intention; it should not be `$child_pid` but instead `$!`.
I've amended the post; thank you.