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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | base/process/launch.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/process/launch.h
diff --git a/base/process/launch.h b/base/process/launch.h
index 0450ddf021e0faa7936bf7118951d050e185251b..ff26225ee51e37caa4fd55fac6f1480dc3552c6a 100644
--- a/base/process/launch.h
+++ b/base/process/launch.h
@@ -37,6 +37,24 @@ typedef std::vector<std::pair<int, int> > FileHandleMappingVector;
// Options for launching a subprocess that are passed to LaunchProcess().
// The default constructor constructs the object with default options.
struct BASE_EXPORT LaunchOptions {
+#if defined(OS_POSIX)
+ // Delegate to be run in between fork and exec in the subprocess (see
+ // pre_exec_delegate below)
+ class BASE_EXPORT PreExecDelegate {
+ public:
+ PreExecDelegate() {}
+ virtual ~PreExecDelegate() {}
+
+ // Since this is to be run between fork and exec, and fork may have happened
+ // while multiple threads were running, this function needs to be async
+ // safe.
+ virtual void RunAsyncSafe() = 0;
+
+ private:
+ DISALLOW_COPY_AND_ASSIGN(PreExecDelegate);
+ };
+#endif // defined(OS_POSIX)
+
LaunchOptions();
~LaunchOptions();
@@ -122,6 +140,14 @@ struct BASE_EXPORT LaunchOptions {
bool allow_new_privs;
#endif // defined(OS_LINUX)
+#if defined(OS_POSIX)
+ // If non-null, a delegate to be run immediately prior to executing the new
+ // program in the child process. Warning: If LaunchProcess was called in the
+ // presence of multiple threads, code running in this delegate essentially
+ // 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.
+ PreExecDelegate* pre_exec_delegate;
+#endif // defined(OS_POSIX)
+
#if defined(OS_CHROMEOS)
// If non-negative, the specified file descriptor will be set as the launched
// process' controlling terminal.
« 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