aboutsummaryrefslogtreecommitdiff
path: root/shell/hush_test
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2011-02-21 03:22:20 +0100
committerDenys Vlasenko <vda.linux@googlemail.com>2011-02-21 03:22:20 +0100
commitb12553faa8991e11c11f70a81f1d9d44078c7645 (patch)
tree4154d5308a9bad6bb46e2014cb6cc997dc9a92cd /shell/hush_test
parent55988aed472d9cd362f9a50f4999b5e47ca33abe (diff)
downloadbusybox-w32-b12553faa8991e11c11f70a81f1d9d44078c7645.tar.gz
busybox-w32-b12553faa8991e11c11f70a81f1d9d44078c7645.tar.bz2
busybox-w32-b12553faa8991e11c11f70a81f1d9d44078c7645.zip
ash: fix ash-signals/signal8 testcase failure
function old new delta killcmd 109 224 +115 kill_main 882 910 +28 changepath 194 195 +1 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 3/0 up/down: 144/0) Total: 144 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'shell/hush_test')
-rw-r--r--shell/hush_test/hush-misc/sigint1.right1
-rwxr-xr-xshell/hush_test/hush-misc/sigint1.tests41
2 files changed, 42 insertions, 0 deletions
diff --git a/shell/hush_test/hush-misc/sigint1.right b/shell/hush_test/hush-misc/sigint1.right
new file mode 100644
index 000000000..a9094b056
--- /dev/null
+++ b/shell/hush_test/hush-misc/sigint1.right
@@ -0,0 +1 @@
Sending SIGINT to main shell PID
diff --git a/shell/hush_test/hush-misc/sigint1.tests b/shell/hush_test/hush-misc/sigint1.tests
new file mode 100755
index 000000000..20e45d940
--- /dev/null
+++ b/shell/hush_test/hush-misc/sigint1.tests
@@ -0,0 +1,41 @@
1# What should happen if non-interactive shell gets SIGINT?
2
3(sleep 1; echo Sending SIGINT to main shell PID; exec kill -INT $$) &
4
5# We create a child which exits with 0 even on SIGINT
6# (This is truly necessary only if SIGINT is generated by ^C,
7# in this testcase even bare "sleep 2" would do because
8# we don't send SIGINT _to_ the_ child_...)
9$THIS_SH -c 'trap "exit 0" SIGINT; sleep 2'
10
11# In one second, we (main shell) get SIGINT here.
12# The question is whether we should, or should not, exit.
13
14# bash will not stop here. It will execute next command(s).
15
16# The rationale for this is described here:
17# http://www.cons.org/cracauer/sigint.html
18#
19# Basically, bash will not exit on SIGINT immediately if it waits
20# for a child. It will wait for the child to exit.
21# If child exits NOT by dying on SIGINT, then bash will not exit.
22#
23# The idea is that the following script:
24# | emacs file.txt
25# | more cmds
26# User may use ^C to interrupt editor's ops like search. But then
27# emacs exits normally. User expects that script doesn't stop.
28#
29# This is a nice idea, but detecting "did process really exit
30# with SIGINT?" is racy. Consider:
31# | bash -c 'while true; do /bin/true; done'
32# When ^C is pressed while bash waits for /bin/true to exit,
33# it may happen that /bin/true exits with exitcode 0 before
34# ^C is delivered to it as SIGINT. bash will see SIGINT, then
35# it will see that child exited with 0, and bash will NOT EXIT.
36
37# Therefore we do not implement bash behavior.
38# I'd say that emacs need to put itself into a separate pgrp
39# to isolate shell from getting stray SIGINTs from ^C.
40
41echo Next command after SIGINT was executed