Index: ipc/ipc_channel_posix.cc |
diff --git a/ipc/ipc_channel_posix.cc b/ipc/ipc_channel_posix.cc |
index 8e74c3a588e73d5255ed9aed6bfbc7321265e59c..24e4c4e345282adb83c3d15a8b231c9b0f888a09 100644 |
--- a/ipc/ipc_channel_posix.cc |
+++ b/ipc/ipc_channel_posix.cc |
@@ -176,9 +176,9 @@ void Channel::NotifyProcessForkedForTesting() { |
//------------------------------------------------------------------------------ |
-#if defined(OS_LINUX) |
+#if defined(OS_LINUX) || defined(OS_NACL_NONSFI) |
int ChannelPosix::global_pid_ = 0; |
-#endif // OS_LINUX |
+#endif // defined(OS_LINUX) || defined(OS_NACL_NONSFI) |
ChannelPosix::ChannelPosix(const IPC::ChannelHandle& channel_handle, |
Mode mode, Listener* listener) |
@@ -645,12 +645,12 @@ bool ChannelPosix::IsNamedServerInitialized( |
return base::PathExists(base::FilePath(channel_id)); |
} |
-#if defined(OS_LINUX) |
+#if defined(OS_LINUX) || defined(OS_NACL_NONSFI) |
// static |
void ChannelPosix::SetGlobalPid(int pid) { |
global_pid_ = pid; |
} |
-#endif // OS_LINUX |
+#endif // defined(OS_LINUX) || defined(OS_NACL_NONSFI) |
// Called by libevent when we can read from the pipe without blocking. |
void ChannelPosix::OnFileCanReadWithoutBlocking(int fd) { |
@@ -771,14 +771,15 @@ void ChannelPosix::ClosePipeOnError() { |
} |
int ChannelPosix::GetHelloMessageProcId() const { |
- int pid = base::GetCurrentProcId(); |
-#if defined(OS_LINUX) |
- // Our process may be in a sandbox with a separate PID namespace. |
- if (global_pid_) { |
- pid = global_pid_; |
- } |
+#if defined(OS_LINUX) || defined(OS_NACL_NONSFI) |
+ // Our process may be in a sandbox with a separate PID namespace in Linux. |
+ // In nacl_helper_nonsfi, getpid() invoked by GetCurrentProcId() is not |
+ // allowed and would cause a SIGSYS crashing because of seccomp sandbox. |
dmichael (off chromium)
2014/11/05 23:48:41
nit: of +the+ seccomp sandbox
hidehiko
2014/11/06 14:19:30
Done.
|
+ // |global_pid_| should be initialized in advance in the process. |
+ if (global_pid_) |
+ return global_pid_; |
#endif |
- return pid; |
+ return base::GetCurrentProcId(); |
} |
void ChannelPosix::QueueHelloMessage() { |
@@ -1111,11 +1112,11 @@ bool Channel::IsNamedServerInitialized( |
return ChannelPosix::IsNamedServerInitialized(channel_id); |
} |
-#if defined(OS_LINUX) |
+#if defined(OS_LINUX) || defined(OS_NACL_NONSFI) |
// static |
void Channel::SetGlobalPid(int pid) { |
ChannelPosix::SetGlobalPid(pid); |
} |
-#endif // OS_LINUX |
+#endif // defined(OS_LINUX) || defined(OS_NACL_NONSFI) |
} // namespace IPC |