32#ifndef ASYNC_EXEC_INCLUDED
33#define ASYNC_EXEC_INCLUDED
44#include <sigc++/sigc++.h>
131class Exec :
public sigc::trackable
137 explicit Exec(
const std::string &cmdline=
"");
159 const std::string &
command(
void)
const {
return args[0]; }
317 typedef std::map<pid_t, Exec*> ExecMap;
319 static ExecMap execs;
320 static int sigchld_pipe[2];
322 static struct sigaction old_sigact;
324 std::vector<std::string> args;
334 static void handleSigChld(
int signal_number, siginfo_t *info,
336 static void sigchldReceived(
void);
342 void subprocessExited(
void);
343 void handleTimeout(
void);
Contains a watch for file descriptors.
Execute external commands.
sigc::signal< void, const char *, int > stderrData
A signal that is emitted when the subprocess write to stderr.
sigc::signal< void > stdoutClosed
A signal that is emitted when the subprocess close its stdout.
bool closeStdin(void)
Close the stdin pipe to the subprocess.
bool writeStdin(const std::string &str)
Write data to stdin on the subprocess.
int exitStatus(void) const
Read the exit code of the subprocess.
bool kill(int sig=SIGTERM)
Send a UNIX signal to the subprocess.
const std::string & command(void) const
Get the command name for the command.
void setTimeout(int time_s)
Set a timeout on the allowed runtime for the subprocess.
Exec(const std::string &cmdline="")
Default constructor.
bool ifExited(void) const
Check if the subprocess exited in a normal way.
bool run(void)
Run the command.
int termSig(void) const
Read the UNIX signal number that caused the subprocess to stop.
void appendArgument(const std::string &arg)
Append a command line argument to a command.
sigc::signal< void > exited
A signal that is emitted when the subprocess exits.
bool writeStdin(const char *buf, int cnt)
Write data to stdin on the subprocess.
bool ifSignaled(void) const
Check if the subprocess exited due to receiving a UNIX signal.
void setCommandLine(const std::string &cmdline)
Set the command line to use.
bool nice(int inc=10)
Modify the nice value for the child subprocess.
sigc::signal< void > stderrClosed
A signal that is emitted when the subprocess close its stderr.
sigc::signal< void, const char *, int > stdoutData
A signal that is emitted when the subprocess write to stdout.
A class for watching file descriptors.
A class that produces timer events.
Namespace for the asynchronous programming classes.