diff options
author | Eric Andersen | 2002-09-26 13:59:40 +0000 |
---|---|---|
committer | Eric Andersen | 2002-09-26 13:59:40 +0000 |
commit | 6f2ebcaa013ea8094a133605a1ae713e446ec965 (patch) | |
tree | 0f8aa0fbf427efffe9ee10001014742550a54101 | |
parent | a920871c3ae0f83ccf9be4c314448cece719b3df (diff) | |
download | busybox-6f2ebcaa013ea8094a133605a1ae713e446ec965.zip busybox-6f2ebcaa013ea8094a133605a1ae713e446ec965.tar.gz |
Avoid calling exit() from within fork/vfork'ed processes.
-Erik
-rw-r--r-- | shell/lash.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/shell/lash.c b/shell/lash.c index 11e7dec..5c4e97f 100644 --- a/shell/lash.c +++ b/shell/lash.c @@ -1214,7 +1214,7 @@ static int pseudo_exec(struct child_prog *child) */ for (x = bltins; x->cmd; x++) { if (strcmp(child->argv[0], x->cmd) == 0 ) { - exit(x->function(child)); + _exit(x->function(child)); } } @@ -1222,7 +1222,7 @@ static int pseudo_exec(struct child_prog *child) for (x = bltins_forking; x->cmd; x++) { if (strcmp(child->argv[0], x->cmd) == 0) { applet_name=x->cmd; - exit (x->function(child)); + _exit (x->function(child)); } } #ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL @@ -1258,7 +1258,11 @@ static int pseudo_exec(struct child_prog *child) #endif execvp(child->argv[0], child->argv); - perror_msg_and_die("%s", child->argv[0]); + + /* Do not use perror_msg_and_die() here, since we must not + * call exit() but should call _exit() instead */ + fprintf(stderr, "%s: %s\n", child->argv[0], strerror(err)); + _exit(EXIT_FAILURE); } static void insert_job(struct job *newjob, int inbg) |