An example of how to use the Exec class
#include <iostream>
using namespace std;
void handleOutput(const char *buf, int cnt)
{
cout << buf;
}
void handleExit(
Exec *exec)
{
cout <<
"Exited(\"" << exec->
command() <<
"\"): ";
{
}
{
cout <<
"term_sig=" << exec->
termSig();
}
cout << endl;
}
int main()
{
cat.stdoutData.connect(sigc::ptr_fun(handleOutput));
cat.stderrData.connect(sigc::ptr_fun(handleOutput));
cat.exited.connect(sigc::bind(sigc::ptr_fun(handleExit), &cat));
cat.nice();
cat.run();
cat.writeStdin("Hello, Exec!\n");
cat.writeStdin("This is a test\n");
cat.closeStdin();
xyz.exited.connect(sigc::bind(sigc::ptr_fun(handleExit), &xyz));
xyz.run();
kill.exited.connect(sigc::bind(sigc::ptr_fun(handleExit), &kill));
kill.setTimeout(1);
kill.run();
Exec sleep(
"/bin/sleep 2");
sleep.exited.connect(sigc::bind(sigc::ptr_fun(handleExit), &sleep));
sleep.exited.connect(mem_fun(app, &CppApplication::quit));
sleep.run();
return 0;
}