3 @@ -4515,6 +4515,7 @@ clear_traps(void)
10 /* Lives far away from here, needed for forkchild */
12 +++ b/shell/ash_test/ash-signals/signal7.right
16 +++ b/shell/ash_test/ash-signals/signal7.tests
20 + # Bug was causing sh to be run in subshell,
21 + # as if this line is replaced with (sh -c ...; exit $?) &
23 + sh -c 'echo REAL_CHILD=$$' &
24 + echo PARENTS_IDEA_OF_CHILD=$!
25 + wait # make sure bkgd shell completes
29 +while read varval; do
32 +test x"$REAL_CHILD" != x"" \
33 +&& test x"$REAL_CHILD" = x"$PARENTS_IDEA_OF_CHILD"
34 +echo "Bug detected: $?"
38 @@ -3901,8 +3901,6 @@ static void insert_bg_job(struct pipe *p
41 printf("[%d] %d %s\n", job->jobid, job->cmds[0].pid, job->cmdtext);
42 - /* Last command's pid goes to $! */
43 - G.last_bg_pid = job->cmds[job->num_cmds - 1].pid;
44 G.last_jobid = job->jobid;
47 @@ -4825,6 +4823,8 @@ static int run_list(struct pipe *pi)
48 if (G.run_list_level == 1)
51 + /* Last command's pid goes to $! */
52 + G.last_bg_pid = pi->cmds[pi->num_cmds - 1].pid;
53 G.last_exitcode = rcode = EXIT_SUCCESS;
54 debug_printf_exec(": cmd&: exitcode EXIT_SUCCESS\n");
57 +++ b/shell/hush_test/hush-trap/signal7.right
61 +++ b/shell/hush_test/hush-trap/signal7.tests
65 + # Bug was causing sh to be run in subshell,
66 + # as if this line is replaced with (sh -c ...; exit $?) &
68 + sh -c 'echo REAL_CHILD=$$' &
69 + echo PARENTS_IDEA_OF_CHILD=$!
70 + wait # make sure bkgd shell completes
74 +while read varval; do
77 +test x"$REAL_CHILD" != x"" \
78 +&& test x"$REAL_CHILD" = x"$PARENTS_IDEA_OF_CHILD"
79 +echo "Bug detected: $?"
81 --- a/shell/shell_common.c
82 +++ b/shell/shell_common.c
83 @@ -428,9 +428,14 @@ shell_builtin_ulimit(char **argv)
84 val <<= l->factor_shift;
86 //bb_error_msg("opt %c val_str:'%s' val:%lld", opt_char, val_str, (long long)val);
87 + /* from man bash: "If neither -H nor -S
88 + * is specified, both the soft and hard
89 + * limits are set. */
91 + opts = OPT_hard + OPT_soft;
94 - if ((opts & OPT_soft) || opts == 0)
95 + if (opts & OPT_soft)
97 //bb_error_msg("setrlimit(%d, %lld, %lld)", l->cmd, (long long)limit.rlim_cur, (long long)limit.rlim_max);
98 if (setrlimit(l->cmd, &limit) < 0) {