From cd55f767270b3effa70f02d806c5525925bd58d8 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 7 Dec 2019 22:39:11 +0100 Subject: [PATCH] Shell: Use _exit() in the forked child if execvp() fails 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. --- Shell/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Shell/main.cpp b/Shell/main.cpp index 43765eb11c..916693332b 100644 --- a/Shell/main.cpp +++ b/Shell/main.cpp @@ -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(); }