Skip to content

Commit

Permalink
Clean up child processes more reliably
Browse files Browse the repository at this point in the history
The current code didn't seem to clean up children on exit. Also,
if there were no children to kill, the following error message
showed up on the console:
./snc.sh: line 1: jobs: unbound variable

This fixes both things by:
- replacing TERM with EXIT
- adding a check that 'jobs' is defined before trying to use it
  • Loading branch information
cfergeau authored and guillaumerose committed Jan 20, 2021
1 parent 16d65fa commit f9e18ae
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion snc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ source tools.sh
source snc-library.sh

# kill all the child processes for this script when it exits
trap 'jobs=($(jobs -p)); ((${#jobs})) && kill "${jobs[@]}" || true; exit 0' TERM
trap 'jobs=($(jobs -p)); [ -n "${jobs-}" ] && ((${#jobs})) && kill "${jobs[@]}" || true; exit 0' EXIT

# If the user set OKD_VERSION in the environment, then use it to override OPENSHIFT_VERSION, MIRROR, and OPENSHIFT_INSTALL_RELEASE_IMAGE_OVERRIDE
# Unless, those variables are explicitly set as well.
Expand Down

0 comments on commit f9e18ae

Please sign in to comment.