summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2016-07-16 18:33:55 +0200
committerDenys Vlasenko2016-07-16 18:33:55 +0200
commite5814a5a42f40274aaadc1187680ffe5c4632c0e (patch)
tree4f0b282b781e4e2da2a02b4171b8d282ad4511b8
parentca003385f1e32646c249dfcd3717afbe7535dcec (diff)
downloadbusybox-e5814a5a42f40274aaadc1187680ffe5c4632c0e.zip
busybox-e5814a5a42f40274aaadc1187680ffe5c4632c0e.tar.gz
ash: do not leave SIGQUIT ignored on "exec CMD"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c15
-rw-r--r--shell/ash_test/ash-signals/sigquit_exec.right2
-rwxr-xr-xshell/ash_test/ash-signals/sigquit_exec.tests4
3 files changed, 20 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c
index faa45a8..4f6376f 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -323,7 +323,7 @@ struct globals_misc {
#define S_DFL 1 /* default signal handling (SIG_DFL) */
#define S_CATCH 2 /* signal is caught */
#define S_IGN 3 /* signal is ignored (SIG_IGN) */
-#define S_HARD_IGN 4 /* signal is ignored permenantly */
+#define S_HARD_IGN 4 /* signal is ignored permanently */
/* indicates specified signal received */
uint8_t gotsig[NSIG - 1]; /* offset by 1: "signal" 0 is meaningless */
@@ -9024,7 +9024,20 @@ execcmd(int argc UNUSED_PARAM, char **argv)
iflag = 0; /* exit on error */
mflag = 0;
optschanged();
+ /* We should set up signals for "exec CMD"
+ * the same way as for "CMD" without "exec".
+ * But optschanged->setinteractive->setsignal
+ * still thought we are a root shell. Therefore, for example,
+ * SIGQUIT is still set to IGN. Fix it:
+ */
+ shlvl++;
+ setsignal(SIGQUIT);
+ /*setsignal(SIGTERM); - unnecessary because of iflag=0 */
+ /*setsignal(SIGTSTP); - unnecessary because of mflag=0 */
+ /*setsignal(SIGTTOU); - unnecessary because of mflag=0 */
+
shellexec(argv + 1, pathval(), 0);
+ /* NOTREACHED */
}
return 0;
}
diff --git a/shell/ash_test/ash-signals/sigquit_exec.right b/shell/ash_test/ash-signals/sigquit_exec.right
new file mode 100644
index 0000000..a804192
--- /dev/null
+++ b/shell/ash_test/ash-signals/sigquit_exec.right
@@ -0,0 +1,2 @@
+SigIgn: 0000000000000000
+SigIgn: 0000000000000000
diff --git a/shell/ash_test/ash-signals/sigquit_exec.tests b/shell/ash_test/ash-signals/sigquit_exec.tests
new file mode 100755
index 0000000..24bda69
--- /dev/null
+++ b/shell/ash_test/ash-signals/sigquit_exec.tests
@@ -0,0 +1,4 @@
+# Should show no masked signals in both cases.
+# We had a bug where SIGQUIT was masked on exec.
+grep SigIgn: /proc/self/status
+exec grep SigIgn: /proc/self/status