Skip to content

Commit 0c8f7fc

Browse files
authored
Merge pull request #7 from pirate/copilot/support-externally-provided-functions
Handle exported-function failures without crashing logging cleanup
2 parents 134508b + 0ceef7b commit 0c8f7fc

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

util/logging.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,11 @@ function fatal {
130130
[ ! -z "${STATUS##*[!0-9]*}" ] || STATUS=3
131131

132132
# kill all child processes in current subshell
133-
jobs -p | xargs 'kill -9 --' 2>/dev/null
133+
local -a CHILD_PIDS=()
134+
mapfile -t CHILD_PIDS < <(jobs -p 2>/dev/null || true)
135+
if (( "${#CHILD_PIDS[@]}" )); then
136+
kill -9 -- "${CHILD_PIDS[@]}" 2>/dev/null || true
137+
fi
134138

135139
exit $STATUS
136140
}
137-

0 commit comments

Comments
 (0)