Skip to content

Commit

Permalink
Shell: Use _exit() in the forked child if execvp() fails
Browse files Browse the repository at this point in the history
If we can't find an executable to exec() after forking, we don't want
to run the atexit() handlers in the child process. Just use _exit()
instead to avoid this.

This was causing us to write out the shell history to ~/.history every
time a "command not found" error was printed.
  • Loading branch information
awesomekling committed Dec 7, 2019
1 parent c399abe commit cd55f76
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Shell/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ static int run_command(const String& cmd)
fprintf(stderr, "%s: Command not found.\n", argv[0]);
else
fprintf(stderr, "execvp(%s): %s\n", argv[0], strerror(errno));
exit(1);
_exit(1);
}
ASSERT_NOT_REACHED();
}
Expand Down

0 comments on commit cd55f76

Please sign in to comment.