[kwlug-disc] bash subprocesses & traps
Chris Frey
cdfrey at foursquare.net
Sun Jul 28 21:47:56 EDT 2024
On Sun, Jul 28, 2024 at 12:18:43PM -0400, John Steel via kwlug-disc wrote:
> finalize() {
> pgrep -fl "cat fifo $FIFO_FILE" > /dev/stderr
> pgrep -fl sha256sum > /dev/stderr
>
> cat_pid="$(cat "$CAT_PID_FILE")"
> rm "$CAT_PID_FILE"
> kill -s SIGTERM "$cat_pid" && wait "$cat_pid"
> exit 0
> }
In my tests, the "exit 0" affects the entire script, not just the
signal handler. Perhaps in combination with SIGTERM, and the exit 0
here, it prevents the sha256sum from completing?
In any case, now that you're not relying on signals to exit your
script, you can get rid of exit 0 here, and SIGTERM should work
just as well as SIGHUP.
That's my guess.
- Chris
More information about the kwlug-disc
mailing list