diff options
-rw-r--r-- | shell/ash.c | 1 | ||||
-rw-r--r-- | shell/ash_test/ash-signals/signal7.right | 1 | ||||
-rwxr-xr-x | shell/ash_test/ash-signals/signal7.tests | 18 | ||||
-rw-r--r-- | shell/hush.c | 4 | ||||
-rw-r--r-- | shell/hush_test/hush-trap/signal7.right | 1 | ||||
-rwxr-xr-x | shell/hush_test/hush-trap/signal7.tests | 18 |
6 files changed, 41 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c index fd119fa51..988edab8a 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
@@ -4633,6 +4633,7 @@ clear_traps(void) | |||
4633 | INT_ON; | 4633 | INT_ON; |
4634 | } | 4634 | } |
4635 | } | 4635 | } |
4636 | may_have_traps = 0; | ||
4636 | } | 4637 | } |
4637 | 4638 | ||
4638 | /* Lives far away from here, needed for forkchild */ | 4639 | /* Lives far away from here, needed for forkchild */ |
diff --git a/shell/ash_test/ash-signals/signal7.right b/shell/ash_test/ash-signals/signal7.right new file mode 100644 index 000000000..ba7453e42 --- /dev/null +++ b/shell/ash_test/ash-signals/signal7.right | |||
@@ -0,0 +1 @@ | |||
Bug detected: 0 | |||
diff --git a/shell/ash_test/ash-signals/signal7.tests b/shell/ash_test/ash-signals/signal7.tests new file mode 100755 index 000000000..c2b1381f9 --- /dev/null +++ b/shell/ash_test/ash-signals/signal7.tests | |||
@@ -0,0 +1,18 @@ | |||
1 | bug() { | ||
2 | trap : exit | ||
3 | # Bug was causing sh to be run in subshell, | ||
4 | # as if this line is replaced with (sh -c ...; exit $?) & | ||
5 | # here: | ||
6 | sh -c 'echo REAL_CHILD=$$' & | ||
7 | echo PARENTS_IDEA_OF_CHILD=$! | ||
8 | wait # make sure bkgd shell completes | ||
9 | } | ||
10 | |||
11 | bug | { | ||
12 | while read varval; do | ||
13 | eval $varval | ||
14 | done | ||
15 | test x"$REAL_CHILD" != x"" \ | ||
16 | && test x"$REAL_CHILD" = x"$PARENTS_IDEA_OF_CHILD" | ||
17 | echo "Bug detected: $?" | ||
18 | } | ||
diff --git a/shell/hush.c b/shell/hush.c index 9208ec497..45c98bb36 100644 --- a/shell/hush.c +++ b/shell/hush.c | |||
@@ -4108,8 +4108,6 @@ static void insert_bg_job(struct pipe *pi) | |||
4108 | 4108 | ||
4109 | if (G_interactive_fd) | 4109 | if (G_interactive_fd) |
4110 | printf("[%d] %d %s\n", job->jobid, job->cmds[0].pid, job->cmdtext); | 4110 | printf("[%d] %d %s\n", job->jobid, job->cmds[0].pid, job->cmdtext); |
4111 | /* Last command's pid goes to $! */ | ||
4112 | G.last_bg_pid = job->cmds[job->num_cmds - 1].pid; | ||
4113 | G.last_jobid = job->jobid; | 4111 | G.last_jobid = job->jobid; |
4114 | } | 4112 | } |
4115 | 4113 | ||
@@ -5076,6 +5074,8 @@ static int run_list(struct pipe *pi) | |||
5076 | if (G.run_list_level == 1) | 5074 | if (G.run_list_level == 1) |
5077 | insert_bg_job(pi); | 5075 | insert_bg_job(pi); |
5078 | #endif | 5076 | #endif |
5077 | /* Last command's pid goes to $! */ | ||
5078 | G.last_bg_pid = pi->cmds[pi->num_cmds - 1].pid; | ||
5079 | G.last_exitcode = rcode = EXIT_SUCCESS; | 5079 | G.last_exitcode = rcode = EXIT_SUCCESS; |
5080 | debug_printf_exec(": cmd&: exitcode EXIT_SUCCESS\n"); | 5080 | debug_printf_exec(": cmd&: exitcode EXIT_SUCCESS\n"); |
5081 | } else { | 5081 | } else { |
diff --git a/shell/hush_test/hush-trap/signal7.right b/shell/hush_test/hush-trap/signal7.right new file mode 100644 index 000000000..ba7453e42 --- /dev/null +++ b/shell/hush_test/hush-trap/signal7.right | |||
@@ -0,0 +1 @@ | |||
Bug detected: 0 | |||
diff --git a/shell/hush_test/hush-trap/signal7.tests b/shell/hush_test/hush-trap/signal7.tests new file mode 100755 index 000000000..c2b1381f9 --- /dev/null +++ b/shell/hush_test/hush-trap/signal7.tests | |||
@@ -0,0 +1,18 @@ | |||
1 | bug() { | ||
2 | trap : exit | ||
3 | # Bug was causing sh to be run in subshell, | ||
4 | # as if this line is replaced with (sh -c ...; exit $?) & | ||
5 | # here: | ||
6 | sh -c 'echo REAL_CHILD=$$' & | ||
7 | echo PARENTS_IDEA_OF_CHILD=$! | ||
8 | wait # make sure bkgd shell completes | ||
9 | } | ||
10 | |||
11 | bug | { | ||
12 | while read varval; do | ||
13 | eval $varval | ||
14 | done | ||
15 | test x"$REAL_CHILD" != x"" \ | ||
16 | && test x"$REAL_CHILD" = x"$PARENTS_IDEA_OF_CHILD" | ||
17 | echo "Bug detected: $?" | ||
18 | } | ||