diff options
author | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 19:11:48 +0000 |
---|---|---|
committer | mdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-23 19:11:48 +0000 |
commit | afa82479fced750ebee50cba4ce94c23ba064ea6 (patch) | |
tree | 731a745fd68437ecd826a92a7c5073531087de1b /base | |
parent | 195e77d6f2d2f615c2a5138750db124853c0a093 (diff) | |
download | chromium_src-afa82479fced750ebee50cba4ce94c23ba064ea6.zip chromium_src-afa82479fced750ebee50cba4ce94c23ba064ea6.tar.gz chromium_src-afa82479fced750ebee50cba4ce94c23ba064ea6.tar.bz2 |
Linux: Use _exit() instead of exit() in the child after fork() in failure conditions.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/159275
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21418 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base')
-rw-r--r-- | base/process_util_linux.cc | 9 | ||||
-rw-r--r-- | base/process_util_posix.cc | 5 |
2 files changed, 12 insertions, 2 deletions
diff --git a/base/process_util_linux.cc b/base/process_util_linux.cc index b784803..50eb4a2 100644 --- a/base/process_util_linux.cc +++ b/base/process_util_linux.cc @@ -113,8 +113,13 @@ bool LaunchApp(const std::vector<std::string>& argv, } } + // Obscure fork() rule: in the child, if you don't end up doing exec*(), + // you call _exit() instead of exit(). This is because _exit() does not + // call any previously-registered (in the parent) exit handlers, which + // might do things like block waiting for threads that don't even exist + // in the child. if (!ShuffleFileDescriptors(fd_shuffle)) - exit(127); + _exit(127); // If we are using the SUID sandbox, it sets a magic environment variable // ("SBX_D"), so we remove that variable from the environment here on the @@ -130,7 +135,7 @@ bool LaunchApp(const std::vector<std::string>& argv, execvp(argv_cstr[0], argv_cstr.get()); LOG(ERROR) << "LaunchApp: exec failed!, argv_cstr[0] " << argv_cstr[0] << ", errno " << errno; - exit(127); + _exit(127); } else { // Parent process if (wait) diff --git a/base/process_util_posix.cc b/base/process_util_posix.cc index a03b45c..6ff660f 100644 --- a/base/process_util_posix.cc +++ b/base/process_util_posix.cc @@ -441,6 +441,11 @@ bool GetAppOutput(const CommandLine& cl, std::string* output) { return false; case 0: // child { + // Obscure fork() rule: in the child, if you don't end up doing exec*(), + // you call _exit() instead of exit(). This is because _exit() does not + // call any previously-registered (in the parent) exit handlers, which + // might do things like block waiting for threads that don't even exist + // in the child. int dev_null = open("/dev/null", O_WRONLY); if (dev_null < 0) _exit(127); |