summaryrefslogtreecommitdiffstats
path: root/base/process_util_linux.cc
diff options
context:
space:
mode:
authormdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 19:11:48 +0000
committermdm@chromium.org <mdm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-23 19:11:48 +0000
commitafa82479fced750ebee50cba4ce94c23ba064ea6 (patch)
tree731a745fd68437ecd826a92a7c5073531087de1b /base/process_util_linux.cc
parent195e77d6f2d2f615c2a5138750db124853c0a093 (diff)
downloadchromium_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/process_util_linux.cc')
-rw-r--r--base/process_util_linux.cc9
1 files changed, 7 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)