← Commit list

6f2ebcaa0

Eric Andersen
Eric Andersen
2002-09-26
FAILED Duration: 6s

Subject

Avoid calling exit() from within fork/vfork'ed processes. -Erik

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/lash.c+7 -3
@@ -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)