| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/zygote/zygote_linux.h" | 5 #include "content/zygote/zygote_linux.h" |
| 6 | 6 |
| 7 #include <fcntl.h> | 7 #include <fcntl.h> |
| 8 #include <string.h> | 8 #include <string.h> |
| 9 #include <sys/socket.h> | 9 #include <sys/socket.h> |
| 10 #include <sys/types.h> | 10 #include <sys/types.h> |
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 if (pid < 0) { | 327 if (pid < 0) { |
| 328 goto error; | 328 goto error; |
| 329 } else if (pid == 0) { | 329 } else if (pid == 0) { |
| 330 // In the child process. | 330 // In the child process. |
| 331 close(pipe_fds[1]); | 331 close(pipe_fds[1]); |
| 332 base::ProcessId real_pid; | 332 base::ProcessId real_pid; |
| 333 // Wait until the parent process has discovered our PID. We | 333 // Wait until the parent process has discovered our PID. We |
| 334 // should not fork any child processes (which the seccomp | 334 // should not fork any child processes (which the seccomp |
| 335 // sandbox does) until then, because that can interfere with the | 335 // sandbox does) until then, because that can interfere with the |
| 336 // parent's discovery of our PID. | 336 // parent's discovery of our PID. |
| 337 if (!file_util::ReadFromFD(pipe_fds[0], | 337 if (!base::ReadFromFD(pipe_fds[0], reinterpret_cast<char*>(&real_pid), |
| 338 reinterpret_cast<char*>(&real_pid), | 338 sizeof(real_pid))) { |
| 339 sizeof(real_pid))) { | |
| 340 LOG(FATAL) << "Failed to synchronise with parent zygote process"; | 339 LOG(FATAL) << "Failed to synchronise with parent zygote process"; |
| 341 } | 340 } |
| 342 if (real_pid <= 0) { | 341 if (real_pid <= 0) { |
| 343 LOG(FATAL) << "Invalid pid from parent zygote"; | 342 LOG(FATAL) << "Invalid pid from parent zygote"; |
| 344 } | 343 } |
| 345 #if defined(OS_LINUX) | 344 #if defined(OS_LINUX) |
| 346 // Sandboxed processes need to send the global, non-namespaced PID when | 345 // Sandboxed processes need to send the global, non-namespaced PID when |
| 347 // setting up an IPC channel to their parent. | 346 // setting up an IPC channel to their parent. |
| 348 IPC::Channel::SetGlobalPid(real_pid); | 347 IPC::Channel::SetGlobalPid(real_pid); |
| 349 // Force the real PID so chrome event data have a PID that corresponds | 348 // Force the real PID so chrome event data have a PID that corresponds |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 544 PickleIterator iter) { | 543 PickleIterator iter) { |
| 545 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != | 544 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != |
| 546 sizeof(sandbox_flags_)) { | 545 sizeof(sandbox_flags_)) { |
| 547 PLOG(ERROR) << "write"; | 546 PLOG(ERROR) << "write"; |
| 548 } | 547 } |
| 549 | 548 |
| 550 return false; | 549 return false; |
| 551 } | 550 } |
| 552 | 551 |
| 553 } // namespace content | 552 } // namespace content |
| OLD | NEW |