OLD | NEW |
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" | |
16 #include "base/callback.h" | 15 #include "base/callback.h" |
17 #include "base/logging.h" | 16 #include "base/logging.h" |
18 #include "base/posix/eintr_wrapper.h" | 17 #include "base/posix/eintr_wrapper.h" |
19 #include "build/build_config.h" | 18 #include "build/build_config.h" |
20 #include "sandbox/linux/services/syscall_wrappers.h" | 19 #include "sandbox/linux/services/syscall_wrappers.h" |
21 #include "sandbox/linux/services/thread_helpers.h" | 20 #include "sandbox/linux/services/thread_helpers.h" |
22 | 21 |
23 namespace sandbox { | 22 namespace sandbox { |
24 | 23 |
25 namespace { | 24 namespace { |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 // It would be problematic if after a fork(), another process would start using | 110 // It would be problematic if after a fork(), another process would start using |
112 // this object. | 111 // this object. |
113 // This method allows to assert it is not happening. | 112 // This method allows to assert it is not happening. |
114 bool ScopedProcess::IsOriginalProcess() { | 113 bool ScopedProcess::IsOriginalProcess() { |
115 // Make a direct syscall to bypass glibc caching of PIDs. | 114 // Make a direct syscall to bypass glibc caching of PIDs. |
116 pid_t pid = sys_getpid(); | 115 pid_t pid = sys_getpid(); |
117 return pid == process_id_; | 116 return pid == process_id_; |
118 } | 117 } |
119 | 118 |
120 } // namespace sandbox | 119 } // namespace sandbox |
OLD | NEW |