diff options
author | Dan Gohman <gohman@apple.com> | 2009-08-05 00:09:12 +0000 |
---|---|---|
committer | Dan Gohman <gohman@apple.com> | 2009-08-05 00:09:12 +0000 |
commit | 23a419f36129d2a9eb4947aa268c8e2072b39f01 (patch) | |
tree | 8bc5a1f129aaa9870ba31f6bfb8ecbc2c6bb0711 /llvm/lib/System/Unix | |
parent | 337b124a24c9ec17d089705677eee8e5f23e2e30 (diff) | |
download | bcm5719-llvm-23a419f36129d2a9eb4947aa268c8e2072b39f01.tar.gz bcm5719-llvm-23a419f36129d2a9eb4947aa268c8e2072b39f01.zip |
Use _exit rather than exit in the child process after a failed exec.
Add a comment explaining why.
llvm-svn: 78128
Diffstat (limited to 'llvm/lib/System/Unix')
-rw-r--r-- | llvm/lib/System/Unix/Program.inc | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/llvm/lib/System/Unix/Program.inc b/llvm/lib/System/Unix/Program.inc index 4814228e138..43a3e7f2833 100644 --- a/llvm/lib/System/Unix/Program.inc +++ b/llvm/lib/System/Unix/Program.inc @@ -200,9 +200,13 @@ Program::Execute(const Path& path, execve(path.c_str(), (char**)args, (char**)envp); else execv(path.c_str(), (char**)args); - // If the execve() failed, we should exit and let the parent pick up - // our non-zero exit status. - exit(errno == ENOENT ? 127 : 126); + // If the execve() failed, we should exit. Follow Unix protocol and + // return 127 if the executable was not found, and 126 otherwise. + // Use _exit rather than exit so that atexit functions and static + // object destructors cloned from the parent process aren't + // redundantly run, and so that any data buffered in stdio buffers + // cloned from the parent aren't redundantly written out. + _exit(errno == ENOENT ? 127 : 126); } // Parent process: Break out of the switch to do our processing. |