diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2016-07-16 18:33:55 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2016-07-16 18:33:55 +0200 |
commit | e5814a5a42f40274aaadc1187680ffe5c4632c0e (patch) | |
tree | 4f0b282b781e4e2da2a02b4171b8d282ad4511b8 | |
parent | ca003385f1e32646c249dfcd3717afbe7535dcec (diff) | |
download | busybox-w32-e5814a5a42f40274aaadc1187680ffe5c4632c0e.tar.gz busybox-w32-e5814a5a42f40274aaadc1187680ffe5c4632c0e.tar.bz2 busybox-w32-e5814a5a42f40274aaadc1187680ffe5c4632c0e.zip |
ash: do not leave SIGQUIT ignored on "exec CMD"
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | shell/ash.c | 15 | ||||
-rw-r--r-- | shell/ash_test/ash-signals/sigquit_exec.right | 2 | ||||
-rwxr-xr-x | shell/ash_test/ash-signals/sigquit_exec.tests | 4 |
3 files changed, 20 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c index faa45a8dc..4f6376f78 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -323,7 +323,7 @@ struct globals_misc { | |||
323 | #define S_DFL 1 /* default signal handling (SIG_DFL) */ | 323 | #define S_DFL 1 /* default signal handling (SIG_DFL) */ |
324 | #define S_CATCH 2 /* signal is caught */ | 324 | #define S_CATCH 2 /* signal is caught */ |
325 | #define S_IGN 3 /* signal is ignored (SIG_IGN) */ | 325 | #define S_IGN 3 /* signal is ignored (SIG_IGN) */ |
326 | #define S_HARD_IGN 4 /* signal is ignored permenantly */ | 326 | #define S_HARD_IGN 4 /* signal is ignored permanently */ |
327 | 327 | ||
328 | /* indicates specified signal received */ | 328 | /* indicates specified signal received */ |
329 | uint8_t gotsig[NSIG - 1]; /* offset by 1: "signal" 0 is meaningless */ | 329 | uint8_t gotsig[NSIG - 1]; /* offset by 1: "signal" 0 is meaningless */ |
@@ -9024,7 +9024,20 @@ execcmd(int argc UNUSED_PARAM, char **argv) | |||
9024 | iflag = 0; /* exit on error */ | 9024 | iflag = 0; /* exit on error */ |
9025 | mflag = 0; | 9025 | mflag = 0; |
9026 | optschanged(); | 9026 | optschanged(); |
9027 | /* We should set up signals for "exec CMD" | ||
9028 | * the same way as for "CMD" without "exec". | ||
9029 | * But optschanged->setinteractive->setsignal | ||
9030 | * still thought we are a root shell. Therefore, for example, | ||
9031 | * SIGQUIT is still set to IGN. Fix it: | ||
9032 | */ | ||
9033 | shlvl++; | ||
9034 | setsignal(SIGQUIT); | ||
9035 | /*setsignal(SIGTERM); - unnecessary because of iflag=0 */ | ||
9036 | /*setsignal(SIGTSTP); - unnecessary because of mflag=0 */ | ||
9037 | /*setsignal(SIGTTOU); - unnecessary because of mflag=0 */ | ||
9038 | |||
9027 | shellexec(argv + 1, pathval(), 0); | 9039 | shellexec(argv + 1, pathval(), 0); |
9040 | /* NOTREACHED */ | ||
9028 | } | 9041 | } |
9029 | return 0; | 9042 | return 0; |
9030 | } | 9043 | } |
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 000000000..a8041929a --- /dev/null +++ b/shell/ash_test/ash-signals/sigquit_exec.right | |||
@@ -0,0 +1,2 @@ | |||
1 | SigIgn: 0000000000000000 | ||
2 | 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 000000000..24bda6921 --- /dev/null +++ b/shell/ash_test/ash-signals/sigquit_exec.tests | |||
@@ -0,0 +1,4 @@ | |||
1 | # Should show no masked signals in both cases. | ||
2 | # We had a bug where SIGQUIT was masked on exec. | ||
3 | grep SigIgn: /proc/self/status | ||
4 | exec grep SigIgn: /proc/self/status | ||