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

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

Issue 831363002: Add the ability to run a callback between fork and exec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Readd closing read end. 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.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) 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 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 #define PR_SET_NO_NEW_PRIVS 38 451 #define PR_SET_NO_NEW_PRIVS 38
452 #endif 452 #endif
453 if (!options.allow_new_privs) { 453 if (!options.allow_new_privs) {
454 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) && errno != EINVAL) { 454 if (prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0) && errno != EINVAL) {
455 // Only log if the error is not EINVAL (i.e. not supported). 455 // Only log if the error is not EINVAL (i.e. not supported).
456 RAW_LOG(FATAL, "prctl(PR_SET_NO_NEW_PRIVS) failed"); 456 RAW_LOG(FATAL, "prctl(PR_SET_NO_NEW_PRIVS) failed");
457 } 457 }
458 } 458 }
459 #endif 459 #endif
460 460
461 #if defined(OS_POSIX)
462 if (options.pre_exec_delegate != nullptr) {
463 options.pre_exec_delegate->RunAsyncSafe();
464 }
465 #endif
466
461 for (size_t i = 0; i < argv.size(); i++) 467 for (size_t i = 0; i < argv.size(); i++)
462 argv_cstr[i] = const_cast<char*>(argv[i].c_str()); 468 argv_cstr[i] = const_cast<char*>(argv[i].c_str());
463 argv_cstr[argv.size()] = NULL; 469 argv_cstr[argv.size()] = NULL;
464 execvp(argv_cstr[0], argv_cstr.get()); 470 execvp(argv_cstr[0], argv_cstr.get());
465 471
466 RAW_LOG(ERROR, "LaunchProcess: failed to execvp:"); 472 RAW_LOG(ERROR, "LaunchProcess: failed to execvp:");
467 RAW_LOG(ERROR, argv_cstr[0]); 473 RAW_LOG(ERROR, argv_cstr[0]);
468 _exit(127); 474 _exit(127);
469 } else { 475 } else {
470 // Parent process 476 // Parent process
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 std::string* output, 689 std::string* output,
684 int* exit_code) { 690 int* exit_code) {
685 // Run |execve()| with the current environment and store "unlimited" data. 691 // Run |execve()| with the current environment and store "unlimited" data.
686 GetAppOutputInternalResult result = GetAppOutputInternal( 692 GetAppOutputInternalResult result = GetAppOutputInternal(
687 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true, 693 cl.argv(), NULL, output, std::numeric_limits<std::size_t>::max(), true,
688 exit_code); 694 exit_code);
689 return result == EXECUTE_SUCCESS; 695 return result == EXECUTE_SUCCESS;
690 } 696 }
691 697
692 } // namespace base 698 } // namespace base
OLDNEW
« no previous file with comments | « base/process/launch.cc ('k') | base/process/process_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698