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

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

Issue 831373002: Move ForkWithFlags from sandbox/ to base/ and plug it into LaunchProcess. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to comments. Created 5 years, 11 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/launch.h ('k') | base/process/process.h » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/launch.h" 5 #include "base/process/launch.h"
6 6
7 #include <dirent.h> 7 #include <dirent.h>
8 #include <errno.h> 8 #include <errno.h>
9 #include <fcntl.h> 9 #include <fcntl.h>
10 #include <signal.h> 10 #include <signal.h>
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 const sigset_t orig_sigmask = SetSignalMask(full_sigset); 304 const sigset_t orig_sigmask = SetSignalMask(full_sigset);
305 305
306 pid_t pid; 306 pid_t pid;
307 #if defined(OS_LINUX) 307 #if defined(OS_LINUX)
308 if (options.clone_flags) { 308 if (options.clone_flags) {
309 // Signal handling in this function assumes the creation of a new 309 // Signal handling in this function assumes the creation of a new
310 // process, so we check that a thread is not being created by mistake 310 // process, so we check that a thread is not being created by mistake
311 // and that signal handling follows the process-creation rules. 311 // and that signal handling follows the process-creation rules.
312 RAW_CHECK( 312 RAW_CHECK(
313 !(options.clone_flags & (CLONE_SIGHAND | CLONE_THREAD | CLONE_VM))); 313 !(options.clone_flags & (CLONE_SIGHAND | CLONE_THREAD | CLONE_VM)));
314 pid = syscall(__NR_clone, options.clone_flags, 0, 0, 0); 314
315 // We specify a null ptid and ctid.
316 RAW_CHECK(
317 !(options.clone_flags &
318 (CLONE_CHILD_CLEARTID | CLONE_CHILD_SETTID | CLONE_PARENT_SETTID)));
319
320 // Since we use waitpid, we do not support custom termination signals in the
321 // clone flags.
322 RAW_CHECK((options.clone_flags & 0xff) == 0);
323
324 pid = ForkWithFlags(options.clone_flags | SIGCHLD, nullptr, nullptr);
315 } else 325 } else
316 #endif 326 #endif
317 { 327 {
318 pid = fork(); 328 pid = fork();
319 } 329 }
320 330
321 // Always restore the original signal mask in the parent. 331 // Always restore the original signal mask in the parent.
322 if (pid != 0) { 332 if (pid != 0) {
323 SetSignalMask(orig_sigmask); 333 SetSignalMask(orig_sigmask);
324 } 334 }
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
664 std::string* output, 674 std::string* output,
665 int* exit_code) { 675 int* exit_code) {
666 // Run |execve()| with the current environment and store "unlimited" data. 676 // Run |execve()| with the current environment and store "unlimited" data.
667 GetAppOutputInternalResult result = GetAppOutputInternal( 677 GetAppOutputInternalResult result = GetAppOutputInternal(
668 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, 678 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true,
669 exit_code); 679 exit_code);
670 return result == EXECUTE_SUCCESS; 680 return result == EXECUTE_SUCCESS;
671 } 681 }
672 682
673 } // namespace base 683 } // namespace base
OLDNEW
« no previous file with comments | « base/process/launch.h ('k') | base/process/process.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698