forked from OSchip/llvm-project
Use _exit rather than exit in the child process after a failed exec.
Add a comment explaining why. llvm-svn: 78128
This commit is contained in:
parent
337b124a24
commit
23a419f361
|
@ -200,9 +200,13 @@ Program::Execute(const Path& path,
|
||||||
execve(path.c_str(), (char**)args, (char**)envp);
|
execve(path.c_str(), (char**)args, (char**)envp);
|
||||||
else
|
else
|
||||||
execv(path.c_str(), (char**)args);
|
execv(path.c_str(), (char**)args);
|
||||||
// If the execve() failed, we should exit and let the parent pick up
|
// If the execve() failed, we should exit. Follow Unix protocol and
|
||||||
// our non-zero exit status.
|
// return 127 if the executable was not found, and 126 otherwise.
|
||||||
exit(errno == ENOENT ? 127 : 126);
|
// 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.
|
// Parent process: Break out of the switch to do our processing.
|
||||||
|
|
Loading…
Reference in New Issue