| OLD | NEW |
| 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 Loading... |
| 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 | 314 pid = syscall(__NR_clone, options.clone_flags, 0, 0, 0); |
| 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); | |
| 325 } else | 315 } else |
| 326 #endif | 316 #endif |
| 327 { | 317 { |
| 328 pid = fork(); | 318 pid = fork(); |
| 329 } | 319 } |
| 330 | 320 |
| 331 // Always restore the original signal mask in the parent. | 321 // Always restore the original signal mask in the parent. |
| 332 if (pid != 0) { | 322 if (pid != 0) { |
| 333 SetSignalMask(orig_sigmask); | 323 SetSignalMask(orig_sigmask); |
| 334 } | 324 } |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 674 std::string* output, | 664 std::string* output, |
| 675 int* exit_code) { | 665 int* exit_code) { |
| 676 // Run |execve()| with the current environment and store "unlimited" data. | 666 // Run |execve()| with the current environment and store "unlimited" data. |
| 677 GetAppOutputInternalResult result = GetAppOutputInternal( | 667 GetAppOutputInternalResult result = GetAppOutputInternal( |
| 678 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, | 668 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, |
| 679 exit_code); | 669 exit_code); |
| 680 return result == EXECUTE_SUCCESS; | 670 return result == EXECUTE_SUCCESS; |
| 681 } | 671 } |
| 682 | 672 |
| 683 } // namespace base | 673 } // namespace base |
| OLD | NEW |