Skip to content

Commit

Permalink
fix: no non-zero exit code after trap
Browse files Browse the repository at this point in the history
If the script exits normally,
  /script.sh: line 1: kill: (-1) - No such process
... with non-zero exit code.
  • Loading branch information
pzhlkj6612 authored Jun 22, 2024
1 parent f66e5f4 commit 43aa3ec
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions script.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ echo "------ the_datetime = ${the_datetime}"

# How do I kill background processes / jobs when my shell script exits? - Stack Overflow
# https://stackoverflow.com/a/2173421

trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT
# https://stackoverflow.com/q/360201/2173421#comment137830234_2173421
trap "trap - SIGTERM && kill -- -$$" SIGINT SIGTERM EXIT || true

#############
# Utilities #
Expand Down

0 comments on commit 43aa3ec

Please sign in to comment.