aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-09-26 13:59:40 +0000
committerEric Andersen <andersen@codepoet.org>2002-09-26 13:59:40 +0000
commit6f2ebcaa013ea8094a133605a1ae713e446ec965 (patch)
tree0f8aa0fbf427efffe9ee10001014742550a54101
parenta920871c3ae0f83ccf9be4c314448cece719b3df (diff)
downloadbusybox-w32-6f2ebcaa013ea8094a133605a1ae713e446ec965.tar.gz
busybox-w32-6f2ebcaa013ea8094a133605a1ae713e446ec965.tar.bz2
busybox-w32-6f2ebcaa013ea8094a133605a1ae713e446ec965.zip
Avoid calling exit() from within fork/vfork'ed processes.
-Erik
-rw-r--r--shell/lash.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/shell/lash.c b/shell/lash.c
index 11e7dec70..5c4e97f4a 100644
--- a/shell/lash.c
+++ b/shell/lash.c
@@ -1214,7 +1214,7 @@ static int pseudo_exec(struct child_prog *child)
1214 */ 1214 */
1215 for (x = bltins; x->cmd; x++) { 1215 for (x = bltins; x->cmd; x++) {
1216 if (strcmp(child->argv[0], x->cmd) == 0 ) { 1216 if (strcmp(child->argv[0], x->cmd) == 0 ) {
1217 exit(x->function(child)); 1217 _exit(x->function(child));
1218 } 1218 }
1219 } 1219 }
1220 1220
@@ -1222,7 +1222,7 @@ static int pseudo_exec(struct child_prog *child)
1222 for (x = bltins_forking; x->cmd; x++) { 1222 for (x = bltins_forking; x->cmd; x++) {
1223 if (strcmp(child->argv[0], x->cmd) == 0) { 1223 if (strcmp(child->argv[0], x->cmd) == 0) {
1224 applet_name=x->cmd; 1224 applet_name=x->cmd;
1225 exit (x->function(child)); 1225 _exit (x->function(child));
1226 } 1226 }
1227 } 1227 }
1228#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL 1228#ifdef CONFIG_FEATURE_SH_STANDALONE_SHELL
@@ -1258,7 +1258,11 @@ static int pseudo_exec(struct child_prog *child)
1258#endif 1258#endif
1259 1259
1260 execvp(child->argv[0], child->argv); 1260 execvp(child->argv[0], child->argv);
1261 perror_msg_and_die("%s", child->argv[0]); 1261
1262 /* Do not use perror_msg_and_die() here, since we must not
1263 * call exit() but should call _exit() instead */
1264 fprintf(stderr, "%s: %s\n", child->argv[0], strerror(err));
1265 _exit(EXIT_FAILURE);
1262} 1266}
1263 1267
1264static void insert_job(struct job *newjob, int inbg) 1268static void insert_job(struct job *newjob, int inbg)