Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(958)

Side by Side Diff: content/zygote/zygote_linux.cc

Issue 1186873006: Add Get/SetUniqueIdForProcess. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use uint32_t, prettify comments Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <stdint.h>
8 #include <string.h> 9 #include <string.h>
9 #include <sys/socket.h> 10 #include <sys/socket.h>
10 #include <sys/types.h> 11 #include <sys/types.h>
11 #include <sys/wait.h> 12 #include <sys/wait.h>
12 13
13 #include "base/command_line.h" 14 #include "base/command_line.h"
14 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
15 #include "base/linux_util.h" 16 #include "base/linux_util.h"
16 #include "base/logging.h" 17 #include "base/logging.h"
17 #include "base/macros.h" 18 #include "base/macros.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // Now read back our real PID from the zygote. 416 // Now read back our real PID from the zygote.
416 base::ProcessId real_pid; 417 base::ProcessId real_pid;
417 if (!base::ReadFromFD(read_pipe.get(), 418 if (!base::ReadFromFD(read_pipe.get(),
418 reinterpret_cast<char*>(&real_pid), 419 reinterpret_cast<char*>(&real_pid),
419 sizeof(real_pid))) { 420 sizeof(real_pid))) {
420 LOG(FATAL) << "Failed to synchronise with parent zygote process"; 421 LOG(FATAL) << "Failed to synchronise with parent zygote process";
421 } 422 }
422 if (real_pid <= 0) { 423 if (real_pid <= 0) {
423 LOG(FATAL) << "Invalid pid from parent zygote"; 424 LOG(FATAL) << "Invalid pid from parent zygote";
424 } 425 }
425 #if defined(OS_LINUX) 426 #if defined(OS_LINUX)
danakj 2015/08/05 19:52:26 btw.. this file is zygote_linux.cc why does it hav
rickyz (no longer on Chrome) 2015/08/13 23:16:55 From looking at filename_rules.gypi, it seems like
426 // Sandboxed processes need to send the global, non-namespaced PID when 427 // Sandboxed processes need to send the global, non-namespaced PID when
427 // setting up an IPC channel to their parent. 428 // setting up an IPC channel to their parent.
428 IPC::Channel::SetGlobalPid(real_pid); 429 IPC::Channel::SetGlobalPid(real_pid);
429 // Force the real PID so chrome event data have a PID that corresponds 430 // Force the real PID so chrome event data have a PID that corresponds
430 // to system trace event data. 431 // to system trace event data.
431 base::trace_event::TraceLog::GetInstance()->SetProcessID( 432 base::trace_event::TraceLog::GetInstance()->SetProcessID(
432 static_cast<int>(real_pid)); 433 static_cast<int>(real_pid));
434 base::SetUniqueIdForProcess(static_cast<uint32_t>(real_pid));
433 #endif 435 #endif
434 return 0; 436 return 0;
435 } 437 }
436 438
437 // In the parent process. 439 // In the parent process.
438 read_pipe.reset(); 440 read_pipe.reset();
439 pid_oracle.reset(); 441 pid_oracle.reset();
440 442
441 // Always receive a real PID from the zygote host, though it might 443 // Always receive a real PID from the zygote host, though it might
442 // be invalid (see below). 444 // be invalid (see below).
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) { 611 bool Zygote::HandleGetSandboxStatus(int fd, base::PickleIterator iter) {
610 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) != 612 if (HANDLE_EINTR(write(fd, &sandbox_flags_, sizeof(sandbox_flags_))) !=
611 sizeof(sandbox_flags_)) { 613 sizeof(sandbox_flags_)) {
612 PLOG(ERROR) << "write"; 614 PLOG(ERROR) << "write";
613 } 615 }
614 616
615 return false; 617 return false;
616 } 618 }
617 619
618 } // namespace content 620 } // namespace content
OLDNEW
« base/process/process_handle.cc ('K') | « base/process/process_handle.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698