1
0

Compare commits

..

No commits in common. "3b740f2e4d8c5bde6f6df4d1a6c617ada4e7afe1" and "b9b85991691b2c0de1b33a8fa760da1b8b49eb6c" have entirely different histories.

3 changed files with 22 additions and 20 deletions

View File

@ -35,8 +35,11 @@ cleanup() {
kill_child_jobs kill_child_jobs
} }
#trap "kill_child_jobs" INT TERM QUIT
#trap date INT TERM QUIT
# From https://unix.stackexchange.com/a/240736 # From https://unix.stackexchange.com/a/240736
for sig in INT QUIT HUP TERM; do for sig in INT QUIT HUP TERM ALRM USR1; do
trap " trap "
cleanup cleanup
trap - $sig EXIT trap - $sig EXIT

19
dash.sh
View File

@ -1,19 +0,0 @@
#!/bin/sh
set -e
# From https://stackoverflow.com/a/360275
kill_child_jobs() {
echo "In kill_child_jobs()..."
# Workaround for https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=482999
tmp="$(mktemp)"
jobs -p > "$tmp"
child_pids=$(cat "$tmp")
for child in $child_pids
do
echo Killing "$child"
# From https://stackoverflow.com/a/11231970
kill "$child" || true
done
rm "$tmp"
}

18
zsh.sh
View File

@ -8,3 +8,21 @@ kill_child_jobs() {
# From https://unix.stackexchange.com/a/544167 # From https://unix.stackexchange.com/a/544167
while kill %% >/dev/null; do :; done while kill %% >/dev/null; do :; done
} }
cleanup() {
kill_child_jobs
}
# From https://unix.stackexchange.com/a/240736
for sig in INT QUIT HUP TERM ALRM USR1; do
trap "
cleanup
trap - $sig EXIT
kill -s $sig "'"$$"' "$sig"
done
trap cleanup EXIT
yes aa &
yes b &
sleep 100 &
wait