OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/process/process.h" | 5 #include "base/process/process.h" |
6 | 6 |
7 #include <sys/resource.h> | 7 #include <sys/resource.h> |
8 #include <sys/wait.h> | 8 #include <sys/wait.h> |
9 | 9 |
10 #include "base/files/scoped_file.h" | 10 #include "base/files/scoped_file.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
242 // On POSIX there are no privileges to set. | 242 // On POSIX there are no privileges to set. |
243 return Open(pid); | 243 return Open(pid); |
244 } | 244 } |
245 | 245 |
246 // static | 246 // static |
247 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { | 247 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { |
248 DCHECK_NE(handle, GetCurrentProcessHandle()); | 248 DCHECK_NE(handle, GetCurrentProcessHandle()); |
249 return Process(handle); | 249 return Process(handle); |
250 } | 250 } |
251 | 251 |
252 #if !defined(OS_LINUX) | 252 #if !defined(OS_LINUX) && !defined(OS_MACOSX) |
253 // static | 253 // static |
254 bool Process::CanBackgroundProcesses() { | 254 bool Process::CanBackgroundProcesses() { |
255 return false; | 255 return false; |
256 } | 256 } |
257 #endif // !defined(OS_LINUX) | 257 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX) |
258 | 258 |
259 bool Process::IsValid() const { | 259 bool Process::IsValid() const { |
260 return process_ != kNullProcessHandle; | 260 return process_ != kNullProcessHandle; |
261 } | 261 } |
262 | 262 |
263 ProcessHandle Process::Handle() const { | 263 ProcessHandle Process::Handle() const { |
264 return process_; | 264 return process_; |
265 } | 265 } |
266 | 266 |
267 Process Process::Duplicate() const { | 267 Process Process::Duplicate() const { |
(...skipping 28 matching lines...) Expand all Loading... | |
296 } | 296 } |
297 | 297 |
298 bool Process::WaitForExit(int* exit_code) { | 298 bool Process::WaitForExit(int* exit_code) { |
299 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); | 299 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); |
300 } | 300 } |
301 | 301 |
302 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { | 302 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { |
303 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); | 303 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); |
304 } | 304 } |
305 | 305 |
306 #if !defined(OS_LINUX) | 306 #if !defined(OS_LINUX) && !defined(OS_MACOSX) |
307 bool Process::IsProcessBackgrounded() const { | 307 bool Process::IsProcessBackgrounded() const { |
308 // See SetProcessBackgrounded(). | 308 // See SetProcessBackgrounded(). |
309 DCHECK(IsValid()); | 309 DCHECK(IsValid()); |
310 return false; | 310 return false; |
311 } | 311 } |
312 | 312 |
313 bool Process::SetProcessBackgrounded(bool value) { | 313 bool Process::SetProcessBackgrounded(bool value) { |
314 // POSIX only allows lowering the priority of a process, so if we | 314 // POSIX only allows lowering the priority of a process, so if we |
315 // were to lower it we wouldn't be able to raise it back to its initial | 315 // were to lower it we wouldn't be able to raise it back to its initial |
316 // priority. | 316 // priority. |
gab
2015/03/09 15:34:50
Update this comment? i.e. we do it on Linux, Chrom
shrike
2015/03/10 00:34:44
I added NOTIMPLEMENTED() to this method, but the u
gab
2015/03/10 12:29:35
No, NOTIMPLEMENTED() simply results in an ERROR LO
| |
317 DCHECK(IsValid()); | 317 DCHECK(IsValid()); |
318 return false; | 318 return false; |
319 } | 319 } |
320 #endif // !defined(OS_LINUX) | 320 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX) |
321 | 321 |
322 int Process::GetPriority() const { | 322 int Process::GetPriority() const { |
323 DCHECK(IsValid()); | 323 DCHECK(IsValid()); |
324 return getpriority(PRIO_PROCESS, process_); | 324 return getpriority(PRIO_PROCESS, process_); |
325 } | 325 } |
326 | 326 |
327 } // namspace base | 327 } // namespace base |
OLD | NEW |