1 #ifndef UVW_PROCESS_INCLUDE_H
2 #define UVW_PROCESS_INCLUDE_H
22 enum class UVProcessFlags: std::underlying_type_t<uv_process_flags> {
23 SETUID = UV_PROCESS_SETUID,
24 SETGID = UV_PROCESS_SETGID,
25 WINDOWS_VERBATIM_ARGUMENTS = UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS,
26 DETACHED = UV_PROCESS_DETACHED,
27 WINDOWS_HIDE = UV_PROCESS_WINDOWS_HIDE,
28 WINDOWS_HIDE_CONSOLE = UV_PROCESS_WINDOWS_HIDE_CONSOLE,
29 WINDOWS_HIDE_GUI = UV_PROCESS_WINDOWS_HIDE_GUI
33 enum class UVStdIOFlags: std::underlying_type_t<uv_stdio_flags> {
34 IGNORE_STREAM = UV_IGNORE,
35 CREATE_PIPE = UV_CREATE_PIPE,
36 INHERIT_FD = UV_INHERIT_FD,
37 INHERIT_STREAM = UV_INHERIT_STREAM,
38 READABLE_PIPE = UV_READABLE_PIPE,
39 WRITABLE_PIPE = UV_WRITABLE_PIPE,
40 OVERLAPPED_PIPE = UV_OVERLAPPED_PIPE
53 explicit ExitEvent(int64_t code,
int sig) noexcept;
66 static void exitCallback(uv_process_t *handle, int64_t exitStatus,
int termSignal);
69 using Process = details::UVProcessFlags;
70 using StdIO = details::UVStdIOFlags;
72 ProcessHandle(ConstructorAccess ca, std::shared_ptr<Loop> ref);
96 static
bool kill(
int pid,
int signum) noexcept;
118 void spawn(const
char *file,
char **args,
char **env =
nullptr);
185 template<typename T, typename U>
187 uv_stdio_container_t container;
188 Flags<StdIO>::Type fgs =
flags;
189 container.
flags =
static_cast<uv_stdio_flags
>(fgs);
190 container.
data.stream = get<uv_stream_t>(stream);
191 poStreamStdio.push_back(std::move(container));
240 std::vector<uv_stdio_container_t> poFdStdio;
241 std::vector<uv_stdio_container_t> poStreamStdio;
251 #include "process.cpp"
Utility class to handle flags.
OSFileDescriptor fd() const
Gets the platform dependent file descriptor equivalent.
The ProcessHandle handle.
ProcessHandle & uid(Uid id)
Sets the child process' user id.
ProcessHandle & stdio(FileHandle fd, Flags< StdIO > flags)
Makes a file descriptor available to the child process.
bool init()
Initializes the handle.
ProcessHandle & cwd(const std::string &path) noexcept
Sets the current working directory for the subprocess.
int pid() noexcept
Gets the PID of the spawned process.
ProcessHandle & stdio(StreamHandle< T, U > &stream, Flags< StdIO > flags)
Makes a stdio handle available to the child process.
static void disableStdIOInheritance() noexcept
Disables inheritance for file descriptors/handles.
void spawn(const char *file, char **args, char **env=nullptr)
spawn Starts the process.
ProcessHandle & flags(Flags< Process > flags) noexcept
Sets flags that control how spawn() behaves.
ProcessHandle & gid(Gid id)
Sets the child process' group id.
static bool kill(int pid, int signum) noexcept
kill Sends the specified signal to the given PID.
std::shared_ptr< R > data() const
Gets user-defined data. uvw won't use this field in any case.
details::UVTypeWrapper< uv_file > FileHandle