ash: fix signal and "set -e" interaction
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
3
shell/ash_test/ash-signals/signal8.right
Normal file
3
shell/ash_test/ash-signals/signal8.right
Normal file
@@ -0,0 +1,3 @@
|
||||
Removing traps
|
||||
End of exit_func
|
||||
Done: 0
|
18
shell/ash_test/ash-signals/signal8.tests
Executable file
18
shell/ash_test/ash-signals/signal8.tests
Executable file
@@ -0,0 +1,18 @@
|
||||
"$THIS_SH" -c '
|
||||
exit_func() {
|
||||
echo "Removing traps"
|
||||
trap - EXIT TERM INT
|
||||
echo "End of exit_func"
|
||||
}
|
||||
set -e
|
||||
trap exit_func EXIT TERM INT
|
||||
sleep 2
|
||||
exit 77
|
||||
' &
|
||||
|
||||
sleep 1
|
||||
# BUG: ash kills -PGRP, but in non-interactive shell we do not create pgrps!
|
||||
# In this case, bash kills by PID, not PGRP.
|
||||
kill -TERM %1
|
||||
wait
|
||||
echo Done: $?
|
3
shell/ash_test/ash-signals/signal9.right
Normal file
3
shell/ash_test/ash-signals/signal9.right
Normal file
@@ -0,0 +1,3 @@
|
||||
Removing traps
|
||||
End of exit_func
|
||||
Done: 0
|
21
shell/ash_test/ash-signals/signal9.tests
Executable file
21
shell/ash_test/ash-signals/signal9.tests
Executable file
@@ -0,0 +1,21 @@
|
||||
# Note: the inner script is a test which checks for a different bug
|
||||
# (ordering between INT handler and exit on "set -e"),
|
||||
# but so far I did not figure out how to simulate it non-interactively.
|
||||
|
||||
"$THIS_SH" -c '
|
||||
exit_func() {
|
||||
echo "Removing traps"
|
||||
trap - EXIT TERM INT
|
||||
echo "End of exit_func"
|
||||
}
|
||||
set -e
|
||||
trap exit_func EXIT TERM INT
|
||||
sleep 2
|
||||
exit 77
|
||||
' &
|
||||
|
||||
child=$!
|
||||
sleep 1
|
||||
kill -TERM $child
|
||||
wait
|
||||
echo Done: $?
|
Reference in New Issue
Block a user