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

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

Issue 1997153002: libchrome: Several upstreamable fixes from libchrome Base URL: https://chromium.googlesource.com/a/chromium/src.git@master
Patch Set: Addressed feedback Created 4 years, 7 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 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 <errno.h> 7 #include <errno.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <sys/resource.h> 9 #include <sys/resource.h>
10 #include <sys/wait.h> 10 #include <sys/wait.h>
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 } 288 }
289 289
290 void Process::Close() { 290 void Process::Close() {
291 process_ = kNullProcessHandle; 291 process_ = kNullProcessHandle;
292 // if the process wasn't terminated (so we waited) or the state 292 // if the process wasn't terminated (so we waited) or the state
293 // wasn't already collected w/ a wait from process_utils, we're gonna 293 // wasn't already collected w/ a wait from process_utils, we're gonna
294 // end up w/ a zombie when it does finally exit. 294 // end up w/ a zombie when it does finally exit.
295 } 295 }
296 296
297 #if !defined(OS_NACL_NONSFI) 297 #if !defined(OS_NACL_NONSFI)
298 bool Process::Terminate(int exit_code, bool wait) const { 298 bool Process::Terminate(int /*exit_code*/, bool wait) const {
299 // exit_code isn't supportable. 299 // exit_code isn't supportable.
300 DCHECK(IsValid()); 300 DCHECK(IsValid());
301 CHECK_GT(process_, 0); 301 CHECK_GT(process_, 0);
302 302
303 bool result = kill(process_, SIGTERM) == 0; 303 bool result = kill(process_, SIGTERM) == 0;
304 if (result && wait) { 304 if (result && wait) {
305 int tries = 60; 305 int tries = 60;
306 306
307 if (RunningOnValgrind()) { 307 if (RunningOnValgrind()) {
308 // Wait for some extra time when running under Valgrind since the child 308 // Wait for some extra time when running under Valgrind since the child
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
357 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); 357 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout);
358 } 358 }
359 359
360 #if !defined(OS_LINUX) 360 #if !defined(OS_LINUX)
361 bool Process::IsProcessBackgrounded() const { 361 bool Process::IsProcessBackgrounded() const {
362 // See SetProcessBackgrounded(). 362 // See SetProcessBackgrounded().
363 DCHECK(IsValid()); 363 DCHECK(IsValid());
364 return false; 364 return false;
365 } 365 }
366 366
367 bool Process::SetProcessBackgrounded(bool value) { 367 bool Process::SetProcessBackgrounded(bool /*value*/) {
368 // Not implemented for POSIX systems other than Linux. With POSIX, if we were 368 // Not implemented for POSIX systems other than Linux. With POSIX, if we were
369 // to lower the process priority we wouldn't be able to raise it back to its 369 // to lower the process priority we wouldn't be able to raise it back to its
370 // initial priority. 370 // initial priority.
371 NOTIMPLEMENTED(); 371 NOTIMPLEMENTED();
372 return false; 372 return false;
373 } 373 }
374 #endif // !defined(OS_LINUX) 374 #endif // !defined(OS_LINUX)
375 375
376 int Process::GetPriority() const { 376 int Process::GetPriority() const {
377 DCHECK(IsValid()); 377 DCHECK(IsValid());
378 return getpriority(PRIO_PROCESS, process_); 378 return getpriority(PRIO_PROCESS, process_);
379 } 379 }
380 380
381 } // namespace base 381 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698