#include <ProcessBuilder.hpp>
Active running process.
Similar design of subprocess.Popen. In c++ I didn't like
◆ Popen() [1/5]
subprocess::Popen::Popen |
( |
| ) |
|
|
inline |
Initialized as empty and invalid
◆ Popen() [2/5]
Starts command with specified options
◆ Popen() [3/5]
Starts command with specified options
◆ Popen() [4/5]
subprocess::Popen::Popen |
( |
const Popen & |
| ) |
|
|
delete |
◆ Popen() [5/5]
subprocess::Popen::Popen |
( |
Popen && |
| ) |
|
◆ ~Popen()
subprocess::Popen::~Popen |
( |
| ) |
|
Waits for process, Closes pipes and destroys any handles.
◆ close()
void subprocess::Popen::close |
( |
| ) |
|
Destructs the object and initializes to basic state
◆ close_cin()
void subprocess::Popen::close_cin |
( |
| ) |
|
|
inline |
◆ ignore_cerr()
void subprocess::Popen::ignore_cerr |
( |
| ) |
|
|
inline |
calls pipe_ignore_and_close on cerr
◆ ignore_cout()
void subprocess::Popen::ignore_cout |
( |
| ) |
|
|
inline |
calls pipe_ignore_and_close on cout
◆ ignore_output()
void subprocess::Popen::ignore_output |
( |
| ) |
|
|
inline |
calls pipe_ignore_and_close on cout, cerr if open
◆ kill()
bool subprocess::Popen::kill |
( |
| ) |
|
equivalent to send_signal(SIGKILL)
◆ operator=() [1/2]
Popen& subprocess::Popen::operator= |
( |
const Popen & |
| ) |
|
|
delete |
◆ operator=() [2/2]
◆ poll()
bool subprocess::Popen::poll |
( |
| ) |
|
- Returns
- true if terminated.
- Exceptions
-
OSError | If os specific error has been encountered. |
◆ send_signal()
bool subprocess::Popen::send_signal |
( |
int |
signal | ) |
|
Send the signal to the process.
On windows SIGKILL does TerminateProcess, SIGINT sends CTRL_C_EVENT, and anything else including SIGTERM sends CTRL_BREAK_EVENT. It is important to note that such signals is sent to all processes including your own and parents. This might result in your application being terminated if you don't handle CTRL_BREAK_EVENT or CTRL_C_EVENT. To mitigate this set the new process group flag using RunBuilder::new_progress_group() to true.
This deviates from pythons subprocess library behavior in which SIGTERM does the equivalent of SIGKILL in python.
◆ terminate()
bool subprocess::Popen::terminate |
( |
| ) |
|
Sends SIGTERM, on windows sends CTRL_BREAK_EVENT
◆ wait()
int subprocess::Popen::wait |
( |
double |
timeout = -1 | ) |
|
Waits for process to finish.
If stdout or stderr is not read from, the child process may be blocked when it tries to write to the respective streams. You must ensure you continue to read from stdout/stderr. Call ignore_output() to spawn threads to ignore the output preventing a deadlock. You can also troll the child by closing your end.
- Parameters
-
timeout | timeout in seconds. Raises TimeoutExpired on timeout. NOT IMPLEMENTED, WILL WAIT FOREVER. |
- Returns
- returncode
- Exceptions
-
◆ args
◆ cerr
Read from this stream to get cerr output of process. This class holds the ownership and will call pipe_close().
◆ cin
Write to this stream to send data to the process. This class holds the ownership and will call pipe_close().
◆ cout
Read from this stream to get output of process. This class holds the ownership and will call pipe_close().
◆ pid
pid_t subprocess::Popen::pid = 0 |
◆ ProcessBuilder
friend subprocess::Popen::ProcessBuilder |
◆ returncode
The exit value of the process. Valid once process is completed
The documentation for this struct was generated from the following file: