| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 // This file contains functions for launching subprocesses. | 5 // This file contains functions for launching subprocesses. |
| 6 | 6 |
| 7 #ifndef BASE_PROCESS_LAUNCH_H_ | 7 #ifndef BASE_PROCESS_LAUNCH_H_ |
| 8 #define BASE_PROCESS_LAUNCH_H_ | 8 #define BASE_PROCESS_LAUNCH_H_ |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| 11 | 11 |
| 12 #include <string> | 12 #include <string> |
| 13 #include <utility> | 13 #include <utility> |
| 14 #include <vector> | 14 #include <vector> |
| 15 | 15 |
| 16 #include "base/base_export.h" | 16 #include "base/base_export.h" |
| 17 #include "base/environment.h" | 17 #include "base/environment.h" |
| 18 #include "base/macros.h" | 18 #include "base/macros.h" |
| 19 #include "base/process/process.h" | 19 #include "base/process/process.h" |
| 20 #include "base/process/process_handle.h" | 20 #include "base/process/process_handle.h" |
| 21 #include "base/strings/string_piece.h" | 21 #include "base/strings/string_piece.h" |
| 22 #include "build/build_config.h" | 22 #include "build/build_config.h" |
| 23 | 23 |
| 24 #if defined(OS_POSIX) | 24 #if defined(OS_POSIX) |
| 25 #include "base/posix/file_descriptor_shuffle.h" | 25 #include "base/posix/file_descriptor_shuffle.h" |
| 26 #elif defined(OS_WIN) | 26 #elif defined(OS_WIN) |
| 27 #include <windows.h> | 27 #include <windows.h> |
| 28 #endif | 28 #endif |
| 29 | 29 |
| 30 #if defined(OS_FUCHSIA) |
| 31 #include <magenta/types.h> |
| 32 #endif |
| 33 |
| 30 namespace base { | 34 namespace base { |
| 31 | 35 |
| 32 class CommandLine; | 36 class CommandLine; |
| 33 | 37 |
| 34 #if defined(OS_WIN) | 38 #if defined(OS_WIN) |
| 35 typedef std::vector<HANDLE> HandlesToInheritVector; | 39 typedef std::vector<HANDLE> HandlesToInheritVector; |
| 36 #endif | 40 #endif |
| 37 // TODO(viettrungluu): Only define this on POSIX? | 41 // TODO(viettrungluu): Only define this on POSIX? |
| 38 typedef std::vector<std::pair<int, int> > FileHandleMappingVector; | 42 typedef std::vector<std::pair<int, int> > FileHandleMappingVector; |
| 39 | 43 |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 int clone_flags = 0; | 150 int clone_flags = 0; |
| 147 | 151 |
| 148 // By default, child processes will have the PR_SET_NO_NEW_PRIVS bit set. If | 152 // By default, child processes will have the PR_SET_NO_NEW_PRIVS bit set. If |
| 149 // true, then this bit will not be set in the new child process. | 153 // true, then this bit will not be set in the new child process. |
| 150 bool allow_new_privs = false; | 154 bool allow_new_privs = false; |
| 151 | 155 |
| 152 // Sets parent process death signal to SIGKILL. | 156 // Sets parent process death signal to SIGKILL. |
| 153 bool kill_on_parent_death = false; | 157 bool kill_on_parent_death = false; |
| 154 #endif // defined(OS_LINUX) | 158 #endif // defined(OS_LINUX) |
| 155 | 159 |
| 160 #if defined(OS_FUCHSIA) |
| 161 // If valid, launches the application in that job object. The process will be |
| 162 // terminated immediately and LaunchProcess() will fail if assignment to the |
| 163 // job object fails. |
| 164 mx_handle_t job_handle = MX_HANDLE_INVALID; |
| 165 #endif // OS_FUCHSIA |
| 166 |
| 156 #if defined(OS_POSIX) | 167 #if defined(OS_POSIX) |
| 157 // If not empty, launch the specified executable instead of | 168 // If not empty, launch the specified executable instead of |
| 158 // cmdline.GetProgram(). This is useful when it is necessary to pass a custom | 169 // cmdline.GetProgram(). This is useful when it is necessary to pass a custom |
| 159 // argv[0]. | 170 // argv[0]. |
| 160 base::FilePath real_path; | 171 base::FilePath real_path; |
| 161 | 172 |
| 162 // If non-null, a delegate to be run immediately prior to executing the new | 173 // If non-null, a delegate to be run immediately prior to executing the new |
| 163 // program in the child process. | 174 // program in the child process. |
| 164 // | 175 // |
| 165 // WARNING: If LaunchProcess is called in the presence of multiple threads, | 176 // WARNING: If LaunchProcess is called in the presence of multiple threads, |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 315 // multiple threads are running, since at the time the fork happened, the | 326 // multiple threads are running, since at the time the fork happened, the |
| 316 // threads could have been in any state (potentially holding locks, etc.). | 327 // threads could have been in any state (potentially holding locks, etc.). |
| 317 // Callers should most likely call execve() in the child soon after calling | 328 // Callers should most likely call execve() in the child soon after calling |
| 318 // this. | 329 // this. |
| 319 BASE_EXPORT pid_t ForkWithFlags(unsigned long flags, pid_t* ptid, pid_t* ctid); | 330 BASE_EXPORT pid_t ForkWithFlags(unsigned long flags, pid_t* ptid, pid_t* ctid); |
| 320 #endif | 331 #endif |
| 321 | 332 |
| 322 } // namespace base | 333 } // namespace base |
| 323 | 334 |
| 324 #endif // BASE_PROCESS_LAUNCH_H_ | 335 #endif // BASE_PROCESS_LAUNCH_H_ |
| OLD | NEW |