31#include <sys/select.h>
46 PROCESS_ERROR_INVALID_ARGUMENT = -1,
47 PROCESS_ERROR_FORK_FAILED = -2,
48 PROCESS_ERROR_EXEC_FAILED = -3,
49 PROCESS_ERROR_PIPE_FAILED = -4,
50 PROCESS_ERROR_MEMORY = -5,
51 PROCESS_ERROR_WAIT_FAILED = -6,
52 PROCESS_ERROR_KILL_FAILED = -7,
53 PROCESS_ERROR_PERMISSION_DENIED = -8,
54 PROCESS_ERROR_IO = -9,
55 PROCESS_ERROR_TIMEOUT = -10,
56 PROCESS_ERROR_WOULD_BLOCK = -11,
57 PROCESS_ERROR_PIPE_CLOSED = -12,
58 PROCESS_ERROR_TERMINATE_FAILED = -13,
59 PROCESS_ERROR_UNKNOWN = -14
71typedef enum { PROCESS_STREAM_STDIN = 0, PROCESS_STREAM_STDOUT = 1, PROCESS_STREAM_STDERR = 2 }
ProcessStream;
94 const char* working_directory;
95 bool inherit_environment;
96 const char*
const* environment;
122 const char* working_directory;
123 bool inherit_environment;
124 char*
const* environment;
126 ExtendedProcessIO io;
136 bool exited_normally;
335 const ExtProcessOptions* options);
350 const char* stdout_file,
const char* stderr_file,
bool append);
Environment variable utilities and safe access functions.
void process_close_redirection(FileRedirection *redirection)
Close and free a file redirection.
ProcessError process_redirect_to_fd(FileRedirection **redirection, int fd, bool close_on_exec)
Create a file redirection from an existing file descriptor.
ProcessError process_run_and_capture(const char *command, const char *const argv[], ProcessOptions *options, int *exit_code)
Run a command and capture its output.
ProcessError process_create(ProcessHandle **handle, const char *command, const char *const argv[], const ProcessOptions *options)
Create a new process When custom environment is provided, command must be an absolute path or relativ...
ProcessError process_redirect_to_file(FileRedirection **redirection, const char *filepath, int flags, unsigned int mode)
Create a new file redirection for a process.
struct FileRedirection FileRedirection
PipeFd pipe_read_fd(PipeHandle *handle)
ProcessError process_terminate(ProcessHandle *handle, bool force)
Terminate a running process.
ProcessStream
Standard IO stream types for redirection.
ProcessError pipe_write(PipeHandle *pipe, const void *buffer, size_t size, size_t *bytes_written, int timeout_ms)
Write data to a pipe.
ProcessError pipe_read(PipeHandle *pipe, void *buffer, size_t size, size_t *bytes_read, int timeout_ms)
Read data from a pipe.
struct PipeHandle PipeHandle
Pipe handle type for IPC (platform-specific details hidden in implementation)
ProcessError pipe_create(PipeHandle **pipe)
Create a new pipe for IPC.
void process_free(ProcessHandle *handle)
Free resources associated with a process handle.
struct ProcessHandle ProcessHandle
Process handle type (platform-specific details hidden in implementation)
ProcessError
Error codes for process operations.
ProcessError process_wait(ProcessHandle *handle, ProcessResult *result, int timeout_ms)
Wait for a process to complete.
bool pipe_read_closed(PipeHandle *handle)
ProcessError process_run_with_file_redirection(ProcessHandle **handle, const char *command, const char *const argv[], const char *stdout_file, const char *stderr_file, bool append)
Create a process that redirects its output from stdout and/or stderr to files.
ProcessError process_run_with_multiwriter(ProcessResult *result, const char *cmd, const char *args[], int output_fds[], int error_fds[])
Run the command in a process that duplicates output to multiple destinations.
PipeFd pipe_write_fd(PipeHandle *handle)
void pipe_close(PipeHandle *pipe)
Close a pipe.
bool pipe_write_closed(PipeHandle *handle)
ProcessError process_create_with_redirection(ProcessHandle **handle, const char *command, const char *const argv[], const ExtProcessOptions *options)
Create a process with extended redirection options.
const char * process_error_string(ProcessError error)
Get a string description of a process error.
ProcessError pipe_set_nonblocking(PipeHandle *pipe, bool nonblocking)
Set non-blocking mode on a pipe.
Options for process creation.
Result information after a process completes.
Windows-specific type definitions and compatibility macros for cross-platform development.