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

Side by Side Diff: base/process/launch.h

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: More comments. 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 | « no previous file | base/process/launch.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 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 <string> 10 #include <string>
(...skipping 19 matching lines...) Expand all
30 30
31 #if defined(OS_WIN) 31 #if defined(OS_WIN)
32 typedef std::vector<HANDLE> HandlesToInheritVector; 32 typedef std::vector<HANDLE> HandlesToInheritVector;
33 #endif 33 #endif
34 // TODO(viettrungluu): Only define this on POSIX? 34 // TODO(viettrungluu): Only define this on POSIX?
35 typedef std::vector<std::pair<int, int> > FileHandleMappingVector; 35 typedef std::vector<std::pair<int, int> > FileHandleMappingVector;
36 36
37 // Options for launching a subprocess that are passed to LaunchProcess(). 37 // Options for launching a subprocess that are passed to LaunchProcess().
38 // The default constructor constructs the object with default options. 38 // The default constructor constructs the object with default options.
39 struct BASE_EXPORT LaunchOptions { 39 struct BASE_EXPORT LaunchOptions {
40 #if defined(OS_POSIX)
41 // Delegate to be run in between fork and exec in the subprocess (see
42 // pre_exec_delegate below)
43 class BASE_EXPORT PreExecDelegate {
44 public:
45 PreExecDelegate() {}
46 virtual ~PreExecDelegate() {}
47
48 // Since this is to be run between fork and exec, and fork may have happened
49 // while multiple threads were running, this function needs to be async
50 // safe.
51 virtual void RunAsyncSafe() = 0;
52
53 private:
54 DISALLOW_COPY_AND_ASSIGN(PreExecDelegate);
55 };
56 #endif // defined(OS_POSIX)
57
40 LaunchOptions(); 58 LaunchOptions();
41 ~LaunchOptions(); 59 ~LaunchOptions();
42 60
43 // If true, wait for the process to complete. 61 // If true, wait for the process to complete.
44 bool wait; 62 bool wait;
45 63
46 #if defined(OS_WIN) 64 #if defined(OS_WIN)
47 bool start_hidden; 65 bool start_hidden;
48 66
49 // If non-null, inherit exactly the list of handles in this vector (these 67 // If non-null, inherit exactly the list of handles in this vector (these
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 133
116 #if defined(OS_LINUX) 134 #if defined(OS_LINUX)
117 // If non-zero, start the process using clone(), using flags as provided. 135 // If non-zero, start the process using clone(), using flags as provided.
118 int clone_flags; 136 int clone_flags;
119 137
120 // By default, child processes will have the PR_SET_NO_NEW_PRIVS bit set. If 138 // By default, child processes will have the PR_SET_NO_NEW_PRIVS bit set. If
121 // true, then this bit will not be set in the new child process. 139 // true, then this bit will not be set in the new child process.
122 bool allow_new_privs; 140 bool allow_new_privs;
123 #endif // defined(OS_LINUX) 141 #endif // defined(OS_LINUX)
124 142
143 #if defined(OS_POSIX)
144 // If non-null, a delegate to be run immediately prior to executing the new
145 // program in the child process. Warning: If LaunchProcess was called in the
146 // presence of multiple threads, code running in this delegate essentially
147 // needs to be async-signal safe.
Lei Zhang 2015/01/08 23:07:07 Maybe mention "man 7 signal" for a list of async s
rickyz (no longer on Chrome) 2015/01/13 17:22:36 Done.
148 PreExecDelegate* pre_exec_delegate;
149 #endif // defined(OS_POSIX)
150
125 #if defined(OS_CHROMEOS) 151 #if defined(OS_CHROMEOS)
126 // If non-negative, the specified file descriptor will be set as the launched 152 // If non-negative, the specified file descriptor will be set as the launched
127 // process' controlling terminal. 153 // process' controlling terminal.
128 int ctrl_terminal_fd; 154 int ctrl_terminal_fd;
129 #endif // defined(OS_CHROMEOS) 155 #endif // defined(OS_CHROMEOS)
130 156
131 #if defined(OS_MACOSX) 157 #if defined(OS_MACOSX)
132 // If this name is non-empty, the new child, after fork() but before exec(), 158 // If this name is non-empty, the new child, after fork() but before exec(),
133 // will look up this server name in the bootstrap namespace. The resulting 159 // will look up this server name in the bootstrap namespace. The resulting
134 // service port will be replaced as the bootstrap port in the child. Because 160 // service port will be replaced as the bootstrap port in the child. Because
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 void ReplaceBootstrapPort(const std::string& replacement_bootstrap_name); 289 void ReplaceBootstrapPort(const std::string& replacement_bootstrap_name);
264 #endif // defined(OS_MACOSX) 290 #endif // defined(OS_MACOSX)
265 291
266 // Creates a LaunchOptions object suitable for launching processes in a test 292 // Creates a LaunchOptions object suitable for launching processes in a test
267 // binary. This should not be called in production/released code. 293 // binary. This should not be called in production/released code.
268 BASE_EXPORT LaunchOptions LaunchOptionsForTest(); 294 BASE_EXPORT LaunchOptions LaunchOptionsForTest();
269 295
270 } // namespace base 296 } // namespace base
271 297
272 #endif // BASE_PROCESS_LAUNCH_H_ 298 #endif // BASE_PROCESS_LAUNCH_H_
OLDNEW
« no previous file with comments | « no previous file | base/process/launch.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698