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

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

Issue 1180693002: Update from https://crrev.com/333737 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: rebased Created 5 years, 6 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
« no previous file with comments | « base/process/process_metrics_win.cc ('k') | base/process/process_unittest.cc » ('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 (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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 #else 186 #else
187 // Currently on Linux we can't handle non child processes. 187 // Currently on Linux we can't handle non child processes.
188 NOTIMPLEMENTED(); 188 NOTIMPLEMENTED();
189 #endif // OS_MACOSX 189 #endif // OS_MACOSX
190 } 190 }
191 191
192 int status; 192 int status;
193 if (!WaitpidWithTimeout(handle, &status, timeout)) 193 if (!WaitpidWithTimeout(handle, &status, timeout))
194 return false; 194 return false;
195 if (WIFSIGNALED(status)) { 195 if (WIFSIGNALED(status)) {
196 *exit_code = -1; 196 if (exit_code)
197 *exit_code = -1;
197 return true; 198 return true;
198 } 199 }
199 if (WIFEXITED(status)) { 200 if (WIFEXITED(status)) {
200 *exit_code = WEXITSTATUS(status); 201 if (exit_code)
202 *exit_code = WEXITSTATUS(status);
201 return true; 203 return true;
202 } 204 }
203 return false; 205 return false;
204 } 206 }
205 #endif // !defined(OS_NACL_NONSFI) 207 #endif // !defined(OS_NACL_NONSFI)
206 208
207 } // namespace 209 } // namespace
208 210
209 namespace base { 211 namespace base {
210 212
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 // On POSIX there are no privileges to set. 248 // On POSIX there are no privileges to set.
247 return Open(pid); 249 return Open(pid);
248 } 250 }
249 251
250 // static 252 // static
251 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) { 253 Process Process::DeprecatedGetProcessFromHandle(ProcessHandle handle) {
252 DCHECK_NE(handle, GetCurrentProcessHandle()); 254 DCHECK_NE(handle, GetCurrentProcessHandle());
253 return Process(handle); 255 return Process(handle);
254 } 256 }
255 257
256 #if !defined(OS_LINUX) 258 #if !defined(OS_LINUX) && !defined(OS_MACOSX)
257 // static 259 // static
258 bool Process::CanBackgroundProcesses() { 260 bool Process::CanBackgroundProcesses() {
259 return false; 261 return false;
260 } 262 }
261 #endif // !defined(OS_LINUX) 263 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX)
262 264
263 bool Process::IsValid() const { 265 bool Process::IsValid() const {
264 return process_ != kNullProcessHandle; 266 return process_ != kNullProcessHandle;
265 } 267 }
266 268
267 ProcessHandle Process::Handle() const { 269 ProcessHandle Process::Handle() const {
268 return process_; 270 return process_;
269 } 271 }
270 272
271 Process Process::Duplicate() const { 273 Process Process::Duplicate() const {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 #endif // !defined(OS_NACL_NONSFI) 348 #endif // !defined(OS_NACL_NONSFI)
347 349
348 bool Process::WaitForExit(int* exit_code) { 350 bool Process::WaitForExit(int* exit_code) {
349 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code); 351 return WaitForExitWithTimeout(TimeDelta::Max(), exit_code);
350 } 352 }
351 353
352 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) { 354 bool Process::WaitForExitWithTimeout(TimeDelta timeout, int* exit_code) {
353 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout); 355 return WaitForExitWithTimeoutImpl(Handle(), exit_code, timeout);
354 } 356 }
355 357
356 #if !defined(OS_LINUX) 358 #if !defined(OS_LINUX) && !defined(OS_MACOSX)
357 bool Process::IsProcessBackgrounded() const { 359 bool Process::IsProcessBackgrounded() const {
358 // See SetProcessBackgrounded(). 360 // See SetProcessBackgrounded().
359 DCHECK(IsValid()); 361 DCHECK(IsValid());
360 return false; 362 return false;
361 } 363 }
362 364
363 bool Process::SetProcessBackgrounded(bool value) { 365 bool Process::SetProcessBackgrounded(bool value) {
364 // POSIX only allows lowering the priority of a process, so if we 366 // Not implemented for POSIX systems other than Mac and Linux. With POSIX, if
365 // were to lower it we wouldn't be able to raise it back to its initial 367 // we were to lower the process priority we wouldn't be able to raise it back
366 // priority. 368 // to its initial priority.
367 DCHECK(IsValid()); 369 NOTIMPLEMENTED();
368 return false; 370 return false;
369 } 371 }
370 #endif // !defined(OS_LINUX) 372 #endif // !defined(OS_LINUX) && !defined(OS_MACOSX)
371 373
372 int Process::GetPriority() const { 374 int Process::GetPriority() const {
373 DCHECK(IsValid()); 375 DCHECK(IsValid());
374 return getpriority(PRIO_PROCESS, process_); 376 return getpriority(PRIO_PROCESS, process_);
375 } 377 }
376 378
377 } // namespace base 379 } // namespace base
OLDNEW
« no previous file with comments | « base/process/process_metrics_win.cc ('k') | base/process/process_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698