Compare commits
3 Commits
b9b8599169
...
3b740f2e4d
Author | SHA1 | Date | |
---|---|---|---|
3b740f2e4d | |||
810147e969 | |||
3a618ee29b |
|
@ -35,11 +35,8 @@ cleanup() {
|
|||
kill_child_jobs
|
||||
}
|
||||
|
||||
#trap "kill_child_jobs" INT TERM QUIT
|
||||
#trap date INT TERM QUIT
|
||||
|
||||
# From https://unix.stackexchange.com/a/240736
|
||||
for sig in INT QUIT HUP TERM ALRM USR1; do
|
||||
for sig in INT QUIT HUP TERM; do
|
||||
trap "
|
||||
cleanup
|
||||
trap - $sig EXIT
|
||||
|
|
19
dash.sh
Executable file
19
dash.sh
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/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
18
zsh.sh
|
@ -8,21 +8,3 @@ kill_child_jobs() {
|
|||
# From https://unix.stackexchange.com/a/544167
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue
Block a user