1#ifndef UVW_PROCESS_INCLUDE_H
2#define UVW_PROCESS_INCLUDE_H
20enum class uvw_process_flags : std::underlying_type_t<uv_process_flags> {
21 SETUID = UV_PROCESS_SETUID,
22 SETGID = UV_PROCESS_SETGID,
23 WINDOWS_VERBATIM_ARGUMENTS = UV_PROCESS_WINDOWS_VERBATIM_ARGUMENTS,
24 DETACHED = UV_PROCESS_DETACHED,
25 WINDOWS_HIDE = UV_PROCESS_WINDOWS_HIDE,
26 WINDOWS_HIDE_CONSOLE = UV_PROCESS_WINDOWS_HIDE_CONSOLE,
27 WINDOWS_HIDE_GUI = UV_PROCESS_WINDOWS_HIDE_GUI,
31enum class uvw_stdio_flags : std::underlying_type_t<uv_stdio_flags> {
32 IGNORE_STREAM = UV_IGNORE,
33 CREATE_PIPE = UV_CREATE_PIPE,
34 INHERIT_FD = UV_INHERIT_FD,
35 INHERIT_STREAM = UV_INHERIT_STREAM,
36 READABLE_PIPE = UV_READABLE_PIPE,
37 WRITABLE_PIPE = UV_WRITABLE_PIPE,
38 OVERLAPPED_PIPE = UV_OVERLAPPED_PIPE,
46 explicit exit_event(int64_t code,
int sig)
noexcept;
59 static void exit_callback(uv_process_t *hndl, int64_t exit_status,
int term_signal);
62 using process_flags = details::uvw_process_flags;
63 using stdio_flags = details::uvw_stdio_flags;
89 static
bool kill(
int pid,
int signum) noexcept;
109 int spawn(const
char *file,
char **args,
char **env =
nullptr);
177 template<typename T, typename U, typename... E>
179 uv_stdio_container_t container;
180 container.
flags =
static_cast<uv_stdio_flags
>(
flags);
181 container.
data.stream =
reinterpret_cast<uv_stream_t *
>(stream.raw());
182 po_stream_stdio.push_back(std::move(container));
230 process_flags po_flags;
231 std::vector<uv_stdio_container_t> po_fd_stdio;
232 std::vector<uv_stdio_container_t> po_stream_stdio;
240# include "process.cpp"
os_file_descriptor fd() const
Gets the platform dependent file descriptor equivalent.
process_handle & stdio(file_handle fd, stdio_flags flags)
Makes a file descriptor available to the child process.
process_handle & gid(gid_type id)
Sets the child process' group id.
int spawn(const char *file, char **args, char **env=nullptr)
spawn Starts the process.
process_handle & flags(process_flags flags) noexcept
Sets flags that control how spawn() behaves.
int init() final
Initializes the handle.
static bool kill(int pid, int signum) noexcept
kill Sends the specified signal to the given PID.
process_handle & uid(uid_type id)
Sets the child process' user id.
process_handle & stdio(stream_handle< T, U, E... > &stream, stdio_flags flags)
Makes a stdio handle available to the child process.
int pid() noexcept
Gets the PID of the spawned process.
process_handle & cwd(const std::string &path) noexcept
Sets the current working directory for the subprocess.
static void disable_stdio_inheritance() noexcept
Disables inheritance for file descriptors/handles.
std::shared_ptr< R > data() const
Gets user-defined data. uvw won't use this field in any case.
details::uv_type_wrapper< uv_file > file_handle