All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Public Member Functions | List of all members
process Class Referencefinal

The process class manages an asynchronous process with redirected IO. More...

#include <process.hpp>

Public Member Functions

 process (process const &)=delete
processoperator= (process const &)=delete
bool spawn (native_string const &cmd, std::vector< native_string > const &args=std::vector< native_string >())
 Start the process. More...
void kill ()
 Stops the spawned process. More...
int read (char *buffer, unsigned int len)
 Read data from process. More...
bool write (char const *buffer, unsigned int len)
 Write data data process. More...
bool write (std::string const &s)

Detailed Description

The process class manages an asynchronous process with redirected IO.

No console window is being created.

To use, spawn the process and, since it's blocking, call read from a different thread.


Member Function Documentation

void kill ( )

Stops the spawned process.

This function doesn't actually kill the process, it merely closes the pipes.

Blocks until the process has quit.

int read ( char *  buffer,
unsigned int  len 

Read data from process.

This function blocks

>0 Number of octets read, can be less than requested
0 on EOF
-1 on error.
bool spawn ( native_string const &  cmd,
std::vector< native_string > const &  args = std::vector< native_string >() 

Start the process.

This function takes care of properly quoting and escaping the the program's path and its arguments. Fails if process has already been spawned.

cmdThe path of the program to execute
argsThe command-line arguments for the process.
May return true even if the process cannot be started. In that case, trying to read from the process will fail with an error or EOF.
bool write ( char const *  buffer,
unsigned int  len 

Write data data process.

This function blocks

true if all octets have been written.
false on error.

The documentation for this class was generated from the following file: