using namespace std;
using namespace Msp;
-ExternalTask::ExternalTask(const vector<string> &argv, const FS::Path &work_dir):
+ExternalTask::ExternalTask(const vector<string> &a, const FS::Path &wd):
+ argv(a),
+ work_dir(wd),
pid(-1),
exit_code(-1)
{ }
+string ExternalTask::get_command() const
+{
+ string cmd;
+ for(vector<string>::const_iterator i=argv.begin(); i!=argv.end(); ++i)
+ {
+ if(i!=argv.begin())
+ cmd += ' ';
+
+ for(string::const_iterator j=i->begin(); j!=i->end(); ++j)
+ {
+ if(*j=='"' || *j=='\'' || *j==' ' || *j=='\\' || *j=='&')
+ cmd += '\\';
+ cmd += *j;
+ }
+ }
+
+ return cmd;
+}
+
void ExternalTask::start()
{
if((pid = fork()))
class ExternalTask: public Task
{
private:
+ std::vector<std::string> argv;
+ Msp::FS::Path work_dir;
int pid;
int exit_code;
public:
ExternalTask(const std::vector<std::string> &, const Msp::FS::Path &);
+ virtual std::string get_command() const;
virtual void start();
virtual Status check();
};
InternalTask(Worker *);
~InternalTask();
+ virtual std::string get_command() const { return "<internal>"; }
virtual void start();
virtual Status check();
};
#ifndef TASK_H_
#define TASK_H_
+#include <string>
#include <sigc++/signal.h>
class Task
public:
virtual ~Task() { }
+ virtual std::string get_command() const = 0;
virtual void start() = 0;
virtual Status check() = 0;
};