13 #ifndef __PROCESS_SUBPROCESS_HPP__ 14 #define __PROCESS_SUBPROCESS_HPP__ 119 const std::string&
path,
120 std::vector<std::string> argv,
126 const Option<lambda::function<
127 pid_t(
const lambda::function<
int()>&)>>&
clone,
128 const std::vector<Subprocess::ParentHook>& parent_hooks,
129 const std::vector<Subprocess::ChildHook>& child_hooks,
130 const std::vector<int_fd>& whitelist_fds);
140 lambda::function<Try<InputFileDescriptors>()> input;
145 lambda::function<Try<OutputFileDescriptors>()> output;
164 const lambda::function<Try<Nothing>(
pid_t)> parent_setup;
178 #endif // __WINDOWS__ 197 static ChildHook CHDIR(
const std::string& working_directory);
208 static ChildHook DUP2(
int oldFd,
int newFd);
209 #endif // __WINDOWS__ 226 const lambda::function<Try<Nothing>()> child_setup;
231 static IO PATH(
const std::string& path);
294 const std::string& path,
295 std::vector<std::string> argv,
301 const Option<lambda::function<
302 pid_t(
const lambda::function<
int()>&)>>&
clone,
303 const std::vector<Subprocess::ParentHook>& parent_hooks,
304 const std::vector<Subprocess::ChildHook>& child_hooks,
305 const std::vector<int_fd>& whitelist_fds);
311 if (in.isSome()) {
os::close(in.get()); }
312 if (out.isSome()) {
os::close(out.get()); }
313 if (err.isSome()) {
os::close(err.get()); }
320 #endif // __WINDOWS__ 335 std::shared_ptr<Data> data;
367 const std::string& path,
368 std::vector<std::string> argv,
374 const Option<lambda::function<
376 const std::vector<Subprocess::ParentHook>& parent_hooks = {},
377 const std::vector<Subprocess::ChildHook>& child_hooks = {},
378 const std::vector<int_fd>& whitelist_fds = {});
406 const std::string& command,
411 const Option<lambda::function<
413 const std::vector<Subprocess::ParentHook>& parent_hooks = {},
414 const std::vector<Subprocess::ChildHook>& child_hooks = {},
415 const std::vector<int_fd>& whitelist_fds = {})
435 #endif // __PROCESS_SUBPROCESS_HPP__
Option< int_fd > in() const
Definition: subprocess.hpp:244
constexpr const char * arg1
Definition: shell.hpp:43
friend class Subprocess
Definition: subprocess.hpp:116
Try< pid_t > clone(pid_t target, int nstypes, const lambda::function< int()> &f, int flags)
Performs an os::clone after entering a set of namespaces for the specified target process...
Subprocess::IO::OutputFileDescriptors OutputFileDescriptors
Definition: subprocess.hpp:339
A ChildHook can be passed to a subprocess call.
Definition: subprocess.hpp:191
static IO PATH(const std::string &path)
The file descriptor is not duplicated before being passed to the subprocess.
Definition: subprocess.hpp:111
For output file descriptors a child writes to the write file descriptor and a parent may read from th...
Definition: subprocess.hpp:89
pid_t pid() const
Definition: subprocess.hpp:237
#define STDERR_FILENO
Definition: windows.hpp:155
Subprocess::IO::InputFileDescriptors InputFileDescriptors
Definition: subprocess.hpp:338
constexpr const char * arg0
Definition: shell.hpp:42
Represents a fork() exec()ed subprocess.
Definition: subprocess.hpp:44
Environment * environment
DWORD pid_t
Definition: windows.hpp:181
static IO FD(int_fd fd, IO::FDType type=IO::DUPLICATED)
#define STDOUT_FILENO
Definition: windows.hpp:154
Option< int_fd > err() const
Definition: subprocess.hpp:264
Try< Nothing > close(int fd)
Definition: close.hpp:24
Describes how the I/O is redirected for stdin/stdout/stderr.
Definition: subprocess.hpp:62
The file descriptor is duplicated before being passed to the subprocess.
Definition: subprocess.hpp:104
#define STDIN_FILENO
Definition: windows.hpp:153
Option< int_fd > out() const
Definition: subprocess.hpp:254
friend Try< Subprocess > subprocess(const std::string &path, std::vector< std::string > argv, const Subprocess::IO &in, const Subprocess::IO &out, const Subprocess::IO &err, const flags::FlagsBase *flags, const Option< std::map< std::string, std::string >> &environment, const Option< lambda::function< pid_t(const lambda::function< int()> &)>> &clone, const std::vector< Subprocess::ParentHook > &parent_hooks, const std::vector< Subprocess::ChildHook > &child_hooks, const std::vector< int_fd > &whitelist_fds)
FDType
Describes the lifecycle of a file descriptor passed into a subprocess via the Subprocess::FD helper...
Definition: subprocess.hpp:99
Definition: executor.hpp:48
Try< uint32_t > type(const std::string &path)
A hook can be passed to a subprocess call.
Definition: subprocess.hpp:153
int int_fd
Definition: int_fd.hpp:35
constexpr const char * name
Definition: shell.hpp:41
Future< Option< int > > status() const
Exit status of this subprocess captured as a Future (completed when the subprocess exits)...
Definition: subprocess.hpp:290
Try< Nothing > operator()() const
Definition: subprocess.hpp:221
Definition: future.hpp:58