summaryrefslogtreecommitdiffstats
path: root/base/process_util.h
diff options
context:
space:
mode:
authorjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-17 22:41:50 +0000
committerjeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-12-17 22:41:50 +0000
commitfa3097a6a5ec6c6e7c092a6339c283dc34d42ca7 (patch)
tree7fc997f0a3cb9ce2aca5411e43c1987e6618b7d1 /base/process_util.h
parent6f666448fe72b6f98a241cb9d83a2a15aa4ff24e (diff)
downloadchromium_src-fa3097a6a5ec6c6e7c092a6339c283dc34d42ca7.zip
chromium_src-fa3097a6a5ec6c6e7c092a6339c283dc34d42ca7.tar.gz
chromium_src-fa3097a6a5ec6c6e7c092a6339c283dc34d42ca7.tar.bz2
* On POSIX, make sure we don't leak FDs when launching child Processes.
* Add a facility to LaunchProcess() to remap a given FD into a child process. This change is needed for 2 reasons: 1)We want to use a socketpair() for IPC, the child process needs a known FD # for it's side of the socket. 2)The OS X Sandbox doesn't close FDs. Review URL: http://codereview.chromium.org/14497 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7175 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/process_util.h')
-rw-r--r--base/process_util.h11
1 files changed, 11 insertions, 0 deletions
diff --git a/base/process_util.h b/base/process_util.h
index 5146c12..c88d341 100644
--- a/base/process_util.h
+++ b/base/process_util.h
@@ -66,6 +66,12 @@ ProcessHandle GetCurrentProcessHandle();
// Win XP SP1 as well.
int GetProcId(ProcessHandle process);
+#if defined(OS_POSIX)
+// Returns the maximum number of files that a process can have open.
+// Returns 0 on error.
+int GetMaxFilesOpenInProcess();
+#endif
+
#if defined(OS_WIN)
// Runs the given application name with the given command line. Normally, the
// first command line argument should be the path to the process, and don't
@@ -87,13 +93,18 @@ bool LaunchApp(const std::wstring& cmdline,
// Runs the application specified in argv[0] with the command line argv.
// Both the elements of argv and argv itself must be terminated with a null
// byte.
+// Before launching all FDs open in the parent process will be marked as
+// close-on-exec. |fds_to_remap| defines a mapping of src fd->dest fd to
+// propagate FDs into the child process.
//
// As above, if wait is true, execute synchronously. The pid will be stored
// in process_handle if that pointer is non-null.
//
// Note that the first argument in argv must point to the filename,
// and must be fully specified.
+typedef std::vector<std::pair<int, int> > file_handle_mapping_vector;
bool LaunchApp(const std::vector<std::string>& argv,
+ const file_handle_mapping_vector& fds_to_remap,
bool wait, ProcessHandle* process_handle);
#endif