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

Side by Side Diff: base/process/process_posix.cc

Issue 989703002: Add support for backgrounding processes on the Mac (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased on tot, rewrapped backgrounging in an experiment. Created 5 years, 8 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright 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"
11 #include "base/logging.h" 11 #include "base/logging.h"
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 // On POSIX there are no privileges to set. 243 // On POSIX there are no privileges to set.
244 return Open(pid); 244 return Open(pid);
245 } 245 }
246 246
247 // static 247 // static
248 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { 248 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) {
249 DCHECK_NE(handle, GetCurrentProcessHandle()); 249 DCHECK_NE(handle, GetCurrentProcessHandle());
250 return Process(handle); 250 return Process(handle);
251 } 251 }
252 252
253 #if !defined(OS_LINUX) 253 #if !defined(OS_LINUX) && !defined(OS_MACOSX)
254 // static 254 // static
255 bool Process::CanBackgroundProcesses() { 255 bool Process::CanBackgroundProcesses() {
256 return false; 256 return false;
257 } 257 }
258 #endif // !defined(OS_LINUX) 258 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX)
259 259
260 bool Process::IsValid() const { 260 bool Process::IsValid() const {
261 return process_ != kNullProcessHandle; 261 return process_ != kNullProcessHandle;
262 } 262 }
263 263
264 ProcessHandle Process::Handle() const { 264 ProcessHandle Process::Handle() const {
265 return process_; 265 return process_;
266 } 266 }
267 267
268 Process Process::Duplicate() const { 268 Process Process::Duplicate() const {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 #endif // !defined(OS_NACL_NONSFI) 343 #endif // !defined(OS_NACL_NONSFI)
344 344
345 bool Process::WaitForExit(int* exit_code) { 345 bool Process::WaitForExit(int* exit_code) {
346 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); 346 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code);
347 } 347 }
348 348
349 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { 349 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) {
350 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); 350 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout);
351 } 351 }
352 352
353 #if !defined(OS_LINUX) 353 #if !defined(OS_LINUX) && !defined(OS_MACOSX)
354 bool Process::IsProcessBackgrounded() const { 354 bool Process::IsProcessBackgrounded() const {
355 // See SetProcessBackgrounded(). 355 // See SetProcessBackgrounded().
356 DCHECK(IsValid()); 356 DCHECK(IsValid());
357 return false; 357 return false;
358 } 358 }
359 359
360 bool Process::SetProcessBackgrounded(bool value) { 360 bool Process::SetProcessBackgrounded(bool value) {
361 // POSIX only allows lowering the priority of a process, so if we 361 // Not implemented for POSIX systems other than Mac and Linux. With POSIX, if
362 // were to lower it we wouldn't be able to raise it back to its initial 362 // we were to lower the process priority we wouldn't be able to raise it back
363 // priority. 363 // to its initial priority.
364 DCHECK(IsValid()); 364 NOTIMPLEMENTED();
365 return false; 365 return false;
366 } 366 }
367 #endif // !defined(OS_LINUX) 367 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX)
368 368
369 int Process::GetPriority() const { 369 int Process::GetPriority() const {
370 DCHECK(IsValid()); 370 DCHECK(IsValid());
371 return getpriority(PRIO_PROCESS, process_); 371 return getpriority(PRIO_PROCESS, process_);
372 } 372 }
373 373
374 } // namespace base 374 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698