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

Unified Diff: base/process/launch_posix.cc

Issue 862133002: Update from https://crrev.com/312398 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: 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 side-by-side diff with in-line comments
Download patch
Index: base/process/launch_posix.cc
diff --git a/base/process/launch_posix.cc b/base/process/launch_posix.cc
index c60cfdc9fc430a181f09d904a20b99b70dbe4740..6c9ed3ff3db801371c3e193f0d933923773c0380 100644
--- a/base/process/launch_posix.cc
+++ b/base/process/launch_posix.cc
@@ -277,9 +277,13 @@ void CloseSuperfluousFds(const base::InjectiveMultimap& saved_mapping) {
}
}
-bool LaunchProcess(const std::vector<std::string>& argv,
- const LaunchOptions& options,
- ProcessHandle* process_handle) {
+Process LaunchProcess(const CommandLine& cmdline,
+ const LaunchOptions& options) {
+ return LaunchProcess(cmdline.argv(), options);
+}
+
+Process LaunchProcess(const std::vector<std::string>& argv,
+ const LaunchOptions& options) {
size_t fd_shuffle_size = 0;
if (options.fds_to_remap) {
fd_shuffle_size = options.fds_to_remap->size();
@@ -311,7 +315,17 @@ bool LaunchProcess(const std::vector<std::string>& argv,
// and that signal handling follows the process-creation rules.
RAW_CHECK(
!(options.clone_flags & (CLONE_SIGHAND | CLONE_THREAD | CLONE_VM)));
- pid = syscall(__NR_clone, options.clone_flags, 0, 0, 0);
+
+ // We specify a null ptid and ctid.
+ RAW_CHECK(
+ !(options.clone_flags &
+ (CLONE_CHILD_CLEARTID | CLONE_CHILD_SETTID | CLONE_PARENT_SETTID)));
+
+ // Since we use waitpid, we do not support custom termination signals in the
+ // clone flags.
+ RAW_CHECK((options.clone_flags & 0xff) == 0);
+
+ pid = ForkWithFlags(options.clone_flags | SIGCHLD, nullptr, nullptr);
} else
#endif
{
@@ -325,7 +339,7 @@ bool LaunchProcess(const std::vector<std::string>& argv,
if (pid < 0) {
DPLOG(ERROR) << "fork";
- return false;
+ return Process();
} else if (pid == 0) {
// Child process
@@ -448,6 +462,12 @@ bool LaunchProcess(const std::vector<std::string>& argv,
}
#endif
+#if defined(OS_POSIX)
+ if (options.pre_exec_delegate != nullptr) {
+ options.pre_exec_delegate->RunAsyncSafe();
+ }
+#endif
+
for (size_t i = 0; i < argv.size(); i++)
argv_cstr[i] = const_cast<char*>(argv[i].c_str());
argv_cstr[argv.size()] = NULL;
@@ -465,37 +485,9 @@ bool LaunchProcess(const std::vector<std::string>& argv,
pid_t ret = HANDLE_EINTR(waitpid(pid, 0, 0));
DPCHECK(ret > 0);
}
-
- if (process_handle)
- *process_handle = pid;
}
- return true;
-}
-
-Process LaunchProcess(const std::vector<std::string>& argv,
- const LaunchOptions& options) {
- ProcessHandle process_handle;
- if (LaunchProcess(argv, options, &process_handle))
- return Process(process_handle);
-
- return Process();
-}
-
-
-bool LaunchProcess(const CommandLine& cmdline,
- const LaunchOptions& options,
- ProcessHandle* process_handle) {
- return LaunchProcess(cmdline.argv(), options, process_handle);
-}
-
-Process LaunchProcess(const CommandLine& cmdline,
- const LaunchOptions& options) {
- ProcessHandle process_handle;
- if (LaunchProcess(cmdline, options, &process_handle))
- return Process(process_handle);
-
- return Process();
+ return Process(pid);
}
void RaiseProcessToHighPriority() {
« no previous file with comments | « base/process/launch.cc ('k') | base/process/launch_win.cc » ('j') | shell/BUILD.gn » ('J')

Powered by Google App Engine
This is Rietveld 408576698