E-MailRelay
|
A class for running an exectuable in a separate process with an asychronous completion callback. More...
#include <gtask.h>
Public Member Functions | |
Task (TaskCallback &, ExceptionSink es, const std::string &exec_error_format=std::string(), const G::Identity &=G::Identity::invalid()) | |
Constructor for an object that can be start()ed or run(). More... | |
~Task () | |
Destructor. More... | |
void | start (const G::ExecutableCommand &commandline) |
Starts the task by spawning a new process with the given command-line and also starting a thread to wait for it. More... | |
void | start (const G::ExecutableCommand &commandline, const G::Environment &env, G::NewProcess::Fd fd_stdin=G::NewProcess::Fd::devnull(), G::NewProcess::Fd fd_stdout=G::NewProcess::Fd::pipe(), G::NewProcess::Fd fd_stderr=G::NewProcess::Fd::devnull(), const G::Path &cd=G::Path()) |
Overload with more control over the execution environment. More... | |
void | stop () |
Attempts to kill the spawned process. More... | |
std::pair< int, std::string > | run (const G::ExecutableCommand &commandline, const G::Environment &env, G::NewProcess::Fd fd_stdin=G::NewProcess::Fd::devnull(), G::NewProcess::Fd fd_stdout=G::NewProcess::Fd::pipe(), G::NewProcess::Fd fd_stderr=G::NewProcess::Fd::devnull(), const G::Path &cd=G::Path()) |
Runs the task synchronously and returns the exit code and pipe output. More... | |
Task (const Task &)=delete | |
Task (Task &&)=delete | |
void | operator= (const Task &)=delete |
void | operator= (Task &&)=delete |
Friends | |
class | GNet::TaskImp |
A class for running an exectuable in a separate process with an asychronous completion callback.
GNet::Task::Task | ( | TaskCallback & | callback, |
ExceptionSink | es, | ||
const std::string & | exec_error_format = std::string() , |
||
const G::Identity & | id = G::Identity::invalid() |
||
) |
Constructor for an object that can be start()ed or run().
The two trailing parameters are passed to the G::NewProcess class.
GNet::Task::~Task | ( | ) |
std::pair< int, std::string > GNet::Task::run | ( | const G::ExecutableCommand & | commandline, |
const G::Environment & | env, | ||
G::NewProcess::Fd | fd_stdin = G::NewProcess::Fd::devnull() , |
||
G::NewProcess::Fd | fd_stdout = G::NewProcess::Fd::pipe() , |
||
G::NewProcess::Fd | fd_stderr = G::NewProcess::Fd::devnull() , |
||
const G::Path & | cd = G::Path() |
||
) |
void GNet::Task::start | ( | const G::ExecutableCommand & | commandline | ) |
Starts the task by spawning a new process with the given command-line and also starting a thread to wait for it.
The wait thread signals completion of the child process via the event loop and the TaskCallback interface. Standard output goes to the pipe and standard error is discarded. Throws Busy if still busy from a prior call to start().
void GNet::Task::start | ( | const G::ExecutableCommand & | commandline, |
const G::Environment & | env, | ||
G::NewProcess::Fd | fd_stdin = G::NewProcess::Fd::devnull() , |
||
G::NewProcess::Fd | fd_stdout = G::NewProcess::Fd::pipe() , |
||
G::NewProcess::Fd | fd_stderr = G::NewProcess::Fd::devnull() , |
||
const G::Path & | cd = G::Path() |
||
) |
Overload with more control over the execution environment.
See also G::NewProcess.
void GNet::Task::stop | ( | ) |
|
friend |