47 G_EXCEPTION( Busy ,
"cannot execute command-line task: still busy from last time" ) ;
50 const std::string & exec_error_format = std::string() ,
92 void operator=(
const Task & ) = delete ;
93 void operator=(
Task && ) = delete ;
97 void done(
int exit_code ,
const std::string & output ) ;
98 void exception( std::exception & ) ;
101 std::unique_ptr<TaskImp> m_imp ;
104 std::string m_exec_error_format ;
118 virtual void onTaskDone(
int exit_status ,
const std::string & pipe_output ) = 0 ;
A tuple containing an ExceptionHandler interface pointer and a bound 'exception source' pointer.
An abstract interface for callbacks from GNet::Task.
virtual ~TaskCallback()=default
Destructor.
virtual void onTaskDone(int exit_status, const std::string &pipe_output)=0
Callback function to signal task completion.
A private implementation class used by GNet::Task.
A class for running an exectuable in a separate process with an asychronous completion callback.
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().
void stop()
Attempts to kill the spawned process.
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 w...
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.
Holds a set of environment variables and also provides static methods to wrap getenv() and putenv().
A structure representing an external program, holding a path and a set of arguments.
A combination of user-id and group-id, with a very low-level interface to the get/set/e/uid/gid funct...
static Identity invalid() noexcept
Returns an invalid identity.
A Path object represents a file system path.
Wraps up a file descriptor for passing to G::NewProcess.