diff options
Diffstat (limited to 'chrome/common')
-rw-r--r-- | chrome/common/ipc_channel_posix.cc | 8 | ||||
-rw-r--r-- | chrome/common/process_watcher_posix.cc | 15 |
2 files changed, 18 insertions, 5 deletions
diff --git a/chrome/common/ipc_channel_posix.cc b/chrome/common/ipc_channel_posix.cc index b7a9666..52cad9d 100644 --- a/chrome/common/ipc_channel_posix.cc +++ b/chrome/common/ipc_channel_posix.cc @@ -20,6 +20,7 @@ #include "base/lock.h" #include "base/logging.h" #include "base/process_util.h" +#include "base/reserved_file_descriptors.h" #include "base/scoped_ptr.h" #include "base/string_util.h" #include "base/singleton.h" @@ -114,10 +115,6 @@ class PipeMap { ChannelToFDMap map_; }; -// This is the file descriptor number that a client process expects to find its -// IPC socket. -static const int kClientChannelFd = 3; - // Used to map a channel name to the equivalent FD # in the client process. int ChannelNameToClientFD(const std::string& channel_id) { // See the large block comment above PipeMap for the reasoning here. @@ -127,6 +124,9 @@ int ChannelNameToClientFD(const std::string& channel_id) { // If we don't find an entry, we assume that the correct value has been // inserted in the magic slot. + // kClientChannelFd is the file descriptor number that a client process + // expects to find its IPC socket; see reserved_file_descriptors.h. + return kClientChannelFd; } diff --git a/chrome/common/process_watcher_posix.cc b/chrome/common/process_watcher_posix.cc index f1ae4f4..497b80b 100644 --- a/chrome/common/process_watcher_posix.cc +++ b/chrome/common/process_watcher_posix.cc @@ -11,6 +11,7 @@ #include "base/eintr_wrapper.h" #include "base/platform_thread.h" +#include "base/zygote_manager.h" // Return true if the given child is dead. This will also reap the process. // Doesn't block. @@ -69,8 +70,20 @@ class BackgroundReaper : public PlatformThread::Delegate { // static void ProcessWatcher::EnsureProcessTerminated(base::ProcessHandle process) { // If the child is already dead, then there's nothing to do - if (IsChildDead(process)) + const int result = HANDLE_EINTR(waitpid(process, NULL, WNOHANG)); + if (result > 0) return; + if (result == -1) { +#if defined(OS_LINUX) + // If it wasn't our child, maybe it was the zygote manager's child + base::ZygoteManager* zm = base::ZygoteManager::Get(); + if (zm) { + zm->EnsureProcessTerminated(process); + return; + } +#endif // defined(OS_LINUX) + NOTREACHED(); + } BackgroundReaper* reaper = new BackgroundReaper(process); PlatformThread::CreateNonJoinable(0, reaper); |