249 int _stdinPipe[2] = {-1, -1};
250 int _stdoutPipe[2] = {-1, -1};
251 int _stderrPipe[2] = {-1, -1};
254 size_t _stdoutTotal = 0;
255 size_t _stderrTotal = 0;
258 void closeFd(
int &
fd);
261 void closeAllPipes();
274 bool collectExitStatus();
Generic memory buffer descriptor with alignment and memory space support.
Definition buffer.h:85
Lightweight error code wrapper for the promeki library.
Definition error.h:39
Simple value type wrapping std::filesystem::path.
Definition filepath.h:27
Dynamic array container wrapping std::vector.
Definition list.h:40
Base object for promeki.
Definition objectbase.h:129
ObjectBase * parent() const
Returns the parent object, if one. nullptr if none.
Definition objectbase.h:258
Subprocess execution with pipe-based I/O.
Definition process.h:46
void setWorkingDirectory(const FilePath &dir)
Sets the working directory for the subprocess.
Definition process.h:110
State
Process state.
Definition process.h:52
@ Running
Process is running.
Definition process.h:55
@ NotRunning
Process is not running.
Definition process.h:53
@ Starting
Process is being started.
Definition process.h:54
PROMEKI_SIGNAL(readyReadStdout)
Emitted when data is available on the child's stdout.
PROMEKI_SIGNAL(readyReadStderr)
Emitted when data is available on the child's stderr.
Buffer readAllStderr()
Reads all available data from the child's stderr.
void setProgram(const String &program)
Sets the program to execute.
Definition process.h:84
void closeWriteChannel()
Closes the write end of the stdin pipe.
PROMEKI_SIGNAL(errorOccurred, Error)
Emitted when an error occurs during subprocess execution.
void setArguments(const List< String > &args)
Sets the argument list for the subprocess.
Definition process.h:96
int exitCode() const
Returns the exit code of the finished process.
Definition process.h:162
ssize_t writeToStdin(const void *buf, size_t bytes)
Writes data to the child's stdin pipe.
Buffer readAllStdout()
Reads all available data from the child's stdout.
Process & operator=(const Process &)=delete
Deleted copy assignment operator (non-copyable).
void setEnvironment(const Map< String, String > &env)
Sets the environment variables for the subprocess.
Definition process.h:124
const String & program() const
Returns the program path.
Definition process.h:78
const List< String > & arguments() const
Returns the argument list.
Definition process.h:90
const Map< String, String > & environment() const
Returns the environment variables for the subprocess.
Definition process.h:116
PROMEKI_SIGNAL(started)
Emitted when the subprocess starts running.
pid_t pid() const
Returns the child process ID.
Definition process.h:182
void kill()
Sends SIGKILL to the child process.
const FilePath & workingDirectory() const
Returns the working directory for the subprocess.
Definition process.h:102
Error waitForFinished(unsigned int timeoutMs=0)
Blocks until the subprocess has finished or the timeout expires.
~Process()
Destructor. Kills the child process if still running.
bool isRunning() const
Returns true if the subprocess is currently running.
Definition process.h:168
State state() const
Returns the current process state.
Definition process.h:174
Process(const Process &)=delete
Deleted copy constructor (non-copyable).
void terminate()
Sends SIGTERM to the child process.
Error waitForStarted(unsigned int timeoutMs=0)
Blocks until the subprocess has started or the timeout expires.
Error start()
Starts the subprocess using the previously set program and arguments.
Process(ObjectBase *parent=nullptr)
Default constructor.
Error start(const String &program, const List< String > &args)
Convenience: sets program and arguments, then starts.
PROMEKI_SIGNAL(finished, int)
Emitted when the subprocess finishes (carries the exit code).
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19