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> |
11 #include <stdlib.h> | 11 #include <stdlib.h> |
12 #include <sys/resource.h> | 12 #include <sys/resource.h> |
13 #include <sys/time.h> | 13 #include <sys/time.h> |
14 #include <sys/types.h> | 14 #include <sys/types.h> |
15 #include <sys/wait.h> | 15 #include <sys/wait.h> |
16 #include <unistd.h> | 16 #include <unistd.h> |
17 | 17 |
18 #include <iterator> | 18 #include <iterator> |
19 #include <limits> | 19 #include <limits> |
20 #include <set> | 20 #include <set> |
21 | 21 |
22 #include "base/allocator/type_profiler_control.h" | 22 #include "base/allocator/type_profiler_control.h" |
23 #include "base/callback.h" | |
mdempsky
2015/01/07 01:03:50
Not needed anymore.
rickyz (no longer on Chrome)
2015/01/07 01:39:07
Done.
| |
23 #include "base/command_line.h" | 24 #include "base/command_line.h" |
24 #include "base/compiler_specific.h" | 25 #include "base/compiler_specific.h" |
25 #include "base/debug/debugger.h" | 26 #include "base/debug/debugger.h" |
26 #include "base/debug/stack_trace.h" | 27 #include "base/debug/stack_trace.h" |
27 #include "base/files/dir_reader_posix.h" | 28 #include "base/files/dir_reader_posix.h" |
28 #include "base/files/file_util.h" | 29 #include "base/files/file_util.h" |
29 #include "base/files/scoped_file.h" | 30 #include "base/files/scoped_file.h" |
30 #include "base/logging.h" | 31 #include "base/logging.h" |
31 #include "base/memory/scoped_ptr.h" | 32 #include "base/memory/scoped_ptr.h" |
32 #include "base/posix/eintr_wrapper.h" | 33 #include "base/posix/eintr_wrapper.h" |
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
441 #define PR_SET_NO_NEW_PRIVS 38 | 442 #define PR_SET_NO_NEW_PRIVS 38 |
442 #endif | 443 #endif |
443 if (!options.allow_new_privs) { | 444 if (!options.allow_new_privs) { |
444 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) && errno != EINVAL) { | 445 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) && errno != EINVAL) { |
445 // Only log if the error is not EINVAL (i.e. not supported). | 446 // Only log if the error is not EINVAL (i.e. not supported). |
446 RAW_LOG(FATAL, "prctl(PR_SET_NO_NEW_PRIVS) failed"); | 447 RAW_LOG(FATAL, "prctl(PR_SET_NO_NEW_PRIVS) failed"); |
447 } | 448 } |
448 } | 449 } |
449 #endif | 450 #endif |
450 | 451 |
452 #if defined(OS_POSIX) | |
453 if (options.pre_exec_delegate != nullptr) { | |
454 options.pre_exec_delegate->RunAsyncSafe(); | |
455 } | |
456 #endif | |
457 | |
451 for (size_t i = 0; i < argv.size(); i++) | 458 for (size_t i = 0; i < argv.size(); i++) |
452 argv_cstr[i] = const_cast<char*>(argv[i].c_str()); | 459 argv_cstr[i] = const_cast<char*>(argv[i].c_str()); |
453 argv_cstr[argv.size()] = NULL; | 460 argv_cstr[argv.size()] = NULL; |
454 execvp(argv_cstr[0], argv_cstr.get()); | 461 execvp(argv_cstr[0], argv_cstr.get()); |
455 | 462 |
456 RAW_LOG(ERROR, "LaunchProcess: failed to execvp:"); | 463 RAW_LOG(ERROR, "LaunchProcess: failed to execvp:"); |
457 RAW_LOG(ERROR, argv_cstr[0]); | 464 RAW_LOG(ERROR, argv_cstr[0]); |
458 _exit(127); | 465 _exit(127); |
459 } else { | 466 } else { |
460 // Parent process | 467 // Parent process |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
664 std::string* output, | 671 std::string* output, |
665 int* exit_code) { | 672 int* exit_code) { |
666 // Run |execve()| with the current environment and store "unlimited" data. | 673 // Run |execve()| with the current environment and store "unlimited" data. |
667 GetAppOutputInternalResult result = GetAppOutputInternal( | 674 GetAppOutputInternalResult result = GetAppOutputInternal( |
668 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, | 675 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, |
669 exit_code); | 676 exit_code); |
670 return result == EXECUTE_SUCCESS; | 677 return result == EXECUTE_SUCCESS; |
671 } | 678 } |
672 | 679 |
673 } // namespace base | 680 } // namespace base |
OLD | NEW |