aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-02-11 08:30:53 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-02-11 08:30:53 +0000
commitc04163a2890a15a6c4428c4b07e2f21a93141b8e (patch)
tree70349ad24b62fc179ce8c1c9e40161041bb6a41d /shell
parent04e11c9209f88b878d6bef0b56a4d8345c89c217 (diff)
downloadbusybox-w32-c04163a2890a15a6c4428c4b07e2f21a93141b8e.tar.gz
busybox-w32-c04163a2890a15a6c4428c4b07e2f21a93141b8e.tar.bz2
busybox-w32-c04163a2890a15a6c4428c4b07e2f21a93141b8e.zip
hush: reset die_sleep to 0 in child after fork
Diffstat (limited to 'shell')
-rw-r--r--shell/hush.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/shell/hush.c b/shell/hush.c
index f3ea1a212..e9d0355f8 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -759,6 +759,7 @@ static void handler_ctrl_z(int sig)
759 return; 759 return;
760 ctrl_z_flag = 1; 760 ctrl_z_flag = 1;
761 if (!pid) { /* child */ 761 if (!pid) { /* child */
762 die_sleep = 0; /* let nofork's xfuncs die */
762 setpgrp(); 763 setpgrp();
763 debug_printf_jobs("set pgrp for child %d ok\n", getpid()); 764 debug_printf_jobs("set pgrp for child %d ok\n", getpid());
764 set_every_sighandler(SIG_DFL); 765 set_every_sighandler(SIG_DFL);
@@ -1899,6 +1900,7 @@ static int run_pipe(struct pipe *pi)
1899 1900
1900 child->pid = BB_MMU ? fork() : vfork(); 1901 child->pid = BB_MMU ? fork() : vfork();
1901 if (!child->pid) { /* child */ 1902 if (!child->pid) { /* child */
1903 die_sleep = 0; /* let nofork's xfuncs die */
1902#if ENABLE_HUSH_JOB 1904#if ENABLE_HUSH_JOB
1903 /* Every child adds itself to new process group 1905 /* Every child adds itself to new process group
1904 * with pgid == pid_of_first_child_in_pipe */ 1906 * with pgid == pid_of_first_child_in_pipe */
@@ -2571,7 +2573,7 @@ static int expand_vars_to_list(char **list, int n, char **posp, char *arg, char
2571 /* Highest bit in first_ch indicates that var is double-quoted */ 2573 /* Highest bit in first_ch indicates that var is double-quoted */
2572 case '$': /* pid */ 2574 case '$': /* pid */
2573 /* FIXME: (echo $$) should still print pid of main shell */ 2575 /* FIXME: (echo $$) should still print pid of main shell */
2574 val = utoa(getpid()); 2576 val = utoa(getpid()); /* rootpid? */
2575 break; 2577 break;
2576 case '!': /* bg pid */ 2578 case '!': /* bg pid */
2577 val = last_bg_pid ? utoa(last_bg_pid) : (char*)""; 2579 val = last_bg_pid ? utoa(last_bg_pid) : (char*)"";
@@ -3237,6 +3239,7 @@ static FILE *generate_stream_from_list(struct pipe *head)
3237 if (pid < 0) 3239 if (pid < 0)
3238 bb_perror_msg_and_die(BB_MMU ? "fork" : "vfork"); 3240 bb_perror_msg_and_die(BB_MMU ? "fork" : "vfork");
3239 if (pid == 0) { /* child */ 3241 if (pid == 0) { /* child */
3242 die_sleep = 0; /* let nofork's xfuncs die */
3240 close(channel[0]); 3243 close(channel[0]);
3241 xmove_fd(channel[1], 1); 3244 xmove_fd(channel[1], 1);
3242 /* Prevent it from trying to handle ctrl-z etc */ 3245 /* Prevent it from trying to handle ctrl-z etc */
@@ -3250,12 +3253,13 @@ static FILE *generate_stream_from_list(struct pipe *head)
3250 * everywhere outside actual command execution. */ 3253 * everywhere outside actual command execution. */
3251 /*set_jobctrl_sighandler(SIG_IGN);*/ 3254 /*set_jobctrl_sighandler(SIG_IGN);*/
3252 set_misc_sighandler(SIG_DFL); 3255 set_misc_sighandler(SIG_DFL);
3253 _exit(run_list(head)); /* leaks memory */ 3256 /* Freeing 'head' here would break NOMMU. */
3257 _exit(run_list(head));
3254 } 3258 }
3255 close(channel[1]); 3259 close(channel[1]);
3256 pf = fdopen(channel[0], "r"); 3260 pf = fdopen(channel[0], "r");
3257 return pf; 3261 return pf;
3258 /* head is freed by the caller */ 3262 /* 'head' is freed by the caller */
3259} 3263}
3260 3264
3261/* Return code is exit status of the process that is run. */ 3265/* Return code is exit status of the process that is run. */
@@ -3878,9 +3882,9 @@ int hush_main(int argc, char **argv)
3878 if (interactive_fd) { 3882 if (interactive_fd) {
3879 /* Looks like they want an interactive shell */ 3883 /* Looks like they want an interactive shell */
3880 setup_job_control(); 3884 setup_job_control();
3881 /* Make xfuncs do cleanup on exit */ 3885 /* -1 is special - makes xfuncs longjmp on exit
3882 die_sleep = -1; /* flag */ 3886 * (we reset die_sleep = 0 whereever we [v]fork) */
3883// FIXME: should we reset die_sleep = 0 whereever we fork? 3887 die_sleep = -1;
3884 if (setjmp(die_jmp)) { 3888 if (setjmp(die_jmp)) {
3885 /* xfunc has failed! die die die */ 3889 /* xfunc has failed! die die die */
3886 hush_exit(xfunc_error_retval); 3890 hush_exit(xfunc_error_retval);