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

Side by Side Diff: sandbox/linux/services/scoped_process.cc

Issue 754433003: Update from https://crrev.com/305340 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month 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
« no previous file with comments | « sandbox/linux/services/credentials.cc ('k') | sandbox/linux/services/syscall_wrappers.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "sandbox/linux/services/scoped_process.h" 5 #include "sandbox/linux/services/scoped_process.h"
6 6
7 #include <fcntl.h> 7 #include <fcntl.h>
8 #include <signal.h> 8 #include <signal.h>
9 #include <sys/stat.h> 9 #include <sys/stat.h>
10 #include <sys/syscall.h> 10 #include <sys/syscall.h>
11 #include <sys/types.h> 11 #include <sys/types.h>
12 #include <sys/wait.h> 12 #include <sys/wait.h>
13 #include <unistd.h> 13 #include <unistd.h>
14 14
15 #include "base/basictypes.h" 15 #include "base/basictypes.h"
16 #include "base/callback.h" 16 #include "base/callback.h"
17 #include "base/logging.h" 17 #include "base/logging.h"
18 #include "base/posix/eintr_wrapper.h" 18 #include "base/posix/eintr_wrapper.h"
19 #include "build/build_config.h" 19 #include "build/build_config.h"
20 #include "sandbox/linux/services/syscall_wrappers.h"
20 #include "sandbox/linux/services/thread_helpers.h" 21 #include "sandbox/linux/services/thread_helpers.h"
21 22
22 namespace sandbox { 23 namespace sandbox {
23 24
24 namespace { 25 namespace {
25 26
26 const char kSynchronisationChar[] = "D"; 27 const char kSynchronisationChar[] = "D";
27 28
28 void WaitForever() { 29 void WaitForever() {
29 while(true) { 30 while(true) {
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 106
106 CHECK_EQ(c, kSynchronisationChar[0]); 107 CHECK_EQ(c, kSynchronisationChar[0]);
107 return true; 108 return true;
108 } 109 }
109 110
110 // It would be problematic if after a fork(), another process would start using 111 // It would be problematic if after a fork(), another process would start using
111 // this object. 112 // this object.
112 // This method allows to assert it is not happening. 113 // This method allows to assert it is not happening.
113 bool ScopedProcess::IsOriginalProcess() { 114 bool ScopedProcess::IsOriginalProcess() {
114 // Make a direct syscall to bypass glibc caching of PIDs. 115 // Make a direct syscall to bypass glibc caching of PIDs.
115 int pid = syscall(__NR_getpid); 116 pid_t pid = sys_getpid();
116 return pid == process_id_; 117 return pid == process_id_;
117 } 118 }
118 119
119 } // namespace sandbox 120 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/linux/services/credentials.cc ('k') | sandbox/linux/services/syscall_wrappers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698