8 #ifndef WPIUTIL_WPI_UV_PROCESS_H_
9 #define WPIUTIL_WPI_UV_PROCESS_H_
16 #include "wpi/Signal.h"
17 #include "wpi/SmallVector.h"
18 #include "wpi/Twine.h"
19 #include "wpi/uv/Handle.h"
59 m_flags |= UV_PROCESS_SETUID;
69 m_flags |= UV_PROCESS_SETGID;
121 char** m_env =
nullptr;
123 unsigned int m_flags = 0;
130 SmallVector<StdioContainer, 4> m_stdio;
141 struct private_init {};
144 explicit Process(
const private_init&) {}
145 ~
Process() noexcept
override =
default;
172 static std::shared_ptr<Process>
Spawn(
173 Loop& loop,
const Twine& file,
char** args,
190 static std::shared_ptr<Process>
Spawn(
191 const std::shared_ptr<Loop>& loop,
const Twine& file,
char** args,
193 return Spawn(*loop, file, args, options);
200 void Kill(
int signum) { Invoke(&uv_process_kill,
GetRaw(), signum); }
208 static int Kill(
int pid,
int signum) noexcept {
return uv_kill(pid, signum); }
226 #endif // WPIUTIL_WPI_UV_PROCESS_H_
uv_pid_t GetPid() const noexcept
Get the process ID.
Definition: Process.h:214
ProcessOptions & SetGid(uv_gid_t gid) noexcept
Set the child process' group id.
Definition: Process.h:67
uv_process_t * GetRaw() const noexcept
Get the underlying handle data structure.
Definition: Handle.h:264
Handle.
Definition: Handle.h:249
static int Kill(int pid, int signum) noexcept
Sends the specified signal to the given PID.
Definition: Process.h:208
static void DisableStdioInheritance()
Disables inheritance for file descriptors / handles that this process inherited from its parent...
Definition: Process.h:156
WPILib C++ utilities (wpiutil) namespace.
Definition: SmallString.h:21
sig::Signal< int64_t, int > exited
Signal generated when the process exits.
Definition: Process.h:220
Process handle.
Definition: Process.h:140
ProcessOptions & SetEnv(char **env)
Set environment variables for the subprocess.
Definition: Process.h:39
Pipe handle.
Definition: Pipe.h:31
ProcessOptions & SetCwd(const Twine &cwd)
Set the current working directory for the subprocess.
Definition: Process.h:48
ProcessOptions & StdioCreatePipe(size_t index, Pipe &pipe, unsigned int flags)
Create a pipe between the child and the parent.
std::string str() const
Return the twine contents as a std::string.
ProcessOptions & StdioInherit(size_t index, int fd)
Inherit a file descriptor from the parent process.
static std::shared_ptr< Process > Spawn(const std::shared_ptr< Loop > &loop, const Twine &file, char **args, const ProcessOptions &options=ProcessOptions{})
Starts a process.
Definition: Process.h:190
ProcessOptions & StdioIgnore(size_t index)
Explicitly ignore a stdio.
Event loop.
Definition: Loop.h:39
Process options.
Definition: Process.h:30
ProcessOptions & SetUid(uv_uid_t uid) noexcept
Set the child process' user id.
Definition: Process.h:57
static std::shared_ptr< Process > Spawn(Loop &loop, const Twine &file, char **args, const ProcessOptions &options=ProcessOptions{})
Starts a process.
void Kill(int signum)
Sends the specified signal to the process.
Definition: Process.h:200
SignalBase is an implementation of the observer pattern, through the use of an emitting object and sl...
Definition: Signal.h:495
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:79
ProcessOptions & SetFlags(unsigned int flags) noexcept
Set flags.
Definition: Process.h:77
ProcessOptions & ClearFlags(unsigned int flags) noexcept
Clear flags.
Definition: Process.h:86