diff options
author | jln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-01 07:03:01 +0000 |
---|---|---|
committer | jln@chromium.org <jln@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-01 07:03:01 +0000 |
commit | 0191cc410235f5830771ac011c347ca39c98d24a (patch) | |
tree | cbc319d2b9bac211dee5fb7c34d8f1d99409faab /content/zygote | |
parent | 42ac7854b1100cdc459b22e283372c8037be66b9 (diff) | |
download | chromium_src-0191cc410235f5830771ac011c347ca39c98d24a.zip chromium_src-0191cc410235f5830771ac011c347ca39c98d24a.tar.gz chromium_src-0191cc410235f5830771ac011c347ca39c98d24a.tar.bz2 |
Zygote Init: close all file descriptors properly
The file descriptor for the socketpair used for the Zygote init process
to synchronize with its child was not closed properly.
BUG=
TEST=
Review URL: https://chromiumcodereview.appspot.com/10456079
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@139983 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/zygote')
-rw-r--r-- | content/zygote/zygote_main_linux.cc | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/content/zygote/zygote_main_linux.cc b/content/zygote/zygote_main_linux.cc index bbc0a0f..5673f09 100644 --- a/content/zygote/zygote_main_linux.cc +++ b/content/zygote/zygote_main_linux.cc @@ -482,13 +482,14 @@ static bool CreateInitProcessReaper() { (void) HANDLE_EINTR(close(content::kZygoteIdFd)); // Tell the child to continue CHECK(HANDLE_EINTR(send(sync_fds[1], "C", 1, MSG_NOSIGNAL)) == 1); + (void) HANDLE_EINTR(close(sync_fds[1])); for (;;) { // Loop until we have reaped our one natural child siginfo_t reaped_child_info; - pid_t reaped_child = + int wait_ret = HANDLE_EINTR(waitid(P_ALL, 0, &reaped_child_info, WEXITED)); - if (reaped_child == -1) + if (wait_ret) _exit(1); if (reaped_child_info.si_pid == child_pid) { int exit_code = 0; @@ -507,7 +508,9 @@ static bool CreateInitProcessReaper() { (void) HANDLE_EINTR(close(sync_fds[1])); shutdown(sync_fds[0], SHUT_WR); char should_continue; - if (HANDLE_EINTR(read(sync_fds[0], &should_continue, 1)) == 1) + int read_ret = HANDLE_EINTR(read(sync_fds[0], &should_continue, 1)); + (void) HANDLE_EINTR(close(sync_fds[0])); + if (read_ret == 1) return true; else return false; |