1#ifndef UVW_PROCESS_INCLUDE_H
2#define UVW_PROCESS_INCLUDE_H
18enum class UVProcessFlags : std::underlying_type_t<uv_process_flags> {
19 SETUID = UV_PROCESS_SETUID,
20 SETGID = UV_PROCESS_SETGID,
21 WINDOWS_VERBATIM_ARGUMENTS = UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS,
22 DETACHED = UV_PROCESS_DETACHED,
23 WINDOWS_HIDE = UV_PROCESS_WINDOWS_HIDE,
24 WINDOWS_HIDE_CONSOLE = UV_PROCESS_WINDOWS_HIDE_CONSOLE,
25 WINDOWS_HIDE_GUI = UV_PROCESS_WINDOWS_HIDE_GUI
28enum class UVStdIOFlags : std::underlying_type_t<uv_stdio_flags> {
29 IGNORE_STREAM = UV_IGNORE,
30 CREATE_PIPE = UV_CREATE_PIPE,
31 INHERIT_FD = UV_INHERIT_FD,
32 INHERIT_STREAM = UV_INHERIT_STREAM,
33 READABLE_PIPE = UV_READABLE_PIPE,
34 WRITABLE_PIPE = UV_WRITABLE_PIPE,
35 OVERLAPPED_PIPE = UV_OVERLAPPED_PIPE
46 explicit ExitEvent(int64_t code,
int sig)
noexcept;
59 static void exitCallback(uv_process_t *handle, int64_t exitStatus,
int termSignal);
62 using Process = details::UVProcessFlags;
63 using StdIO = details::UVStdIOFlags;
65 ProcessHandle(ConstructorAccess ca, std::shared_ptr<Loop> ref);
89 static
bool kill(
int pid,
int signum) noexcept;
111 void spawn(const
char *file,
char **args,
char **env =
nullptr);
178 template<typename T, typename U>
180 uv_stdio_container_t container;
181 Flags<StdIO>::Type fgs =
flags;
182 container.
flags =
static_cast<uv_stdio_flags
>(fgs);
183 container.
data.stream = get<uv_stream_t>(stream);
184 poStreamStdio.push_back(std::move(container));
233 std::vector<uv_stdio_container_t> poFdStdio;
234 std::vector<uv_stdio_container_t> poStreamStdio;
242# include "process.cpp"
Utility class to handle flags.
OSFileDescriptor fd() const
The ProcessHandle handle.
ProcessHandle & flags(Flags< Process > flags) noexcept
Sets flags that control how spawn() behaves.
ProcessHandle & stdio(FileHandle fd, Flags< StdIO > flags)
Makes a file descriptor available to the child process.
bool init()
Initializes the handle.
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.
ProcessHandle & gid(Gid id)
Sets the child process' group id.
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 & uid(Uid id)
Sets the child process' user id.
static bool kill(int pid, int signum) noexcept
kill Sends the specified signal to the given PID.
ProcessHandle & cwd(const std::string &path) noexcept
Sets the current working directory for the subprocess.
std::shared_ptr< R > data() const
Gets user-defined data. uvw won't use this field in any case.
details::UVTypeWrapper< uv_file > FileHandle