// ProcessJob.h #ifndef dial__ProcessJob_H #define dial__ProcessJob_H // David Adams // September 2002 // // ProcessJob is a job that runs an executable as a child process // on the current machine. The application, task and dataset // are specified in the job constructor. The run directory, unix // environment, command and arguments are specified when the job is // submitted. // // The task and dataset are copied to the run directory before the // job is submitted. // // A job is in one of the following states: // FAILED - unrecoverable error; code from error() // READY - ready for task submission // RUNNING - running a task // DONE - task completed (without being killed) // KILLED - task killed with call to kill() // // ChildWatcher is used to monitor a running process. // // Standard output and error are directed to stdout.log and stderr.log // in the run directory. #include #include #ifndef __CINT__ #include #else typedef int pid_t; #endif #include "dataset_util/Environment.h" #include "dataset_util/CommandLine.h" #include "dial_job/Job.h" namespace dial { class ProcessJob : public Job { private: // data // Input data. Environment m_env; std::string m_shellcom; pid_t m_pid; // Filenames (including dir). std::string m_pidfile; public: // functions // Constructor. // jobdir = directory in which to run // runfile = script to run // shellcom = command to execute run script // E.g. "./bin/sh" or "/usr/lsf/bin/lsrun". ProcessJob(JobId jid, const Application& app, const Task& tsk, const dset::Dataset& dst, const JobPreferences prf, std::string jobdir, std::string runfile, std::string runcom ="/bin/sh"); // Conversion constructor. ProcessJob(const Job& job, std::string runcom ="/bin/sh"); // Destructor. ~ProcessJob(); // Start a job. // If successful, this returns 0 and leaves object in RUNNING. // Succeeds at most once. int start(); // Update the status of a job. int update(); // Kill the job. int kill(int err =0); public: // const functions // Getters. pid_t process_id() const { return m_pid; } // Output stream. std::ostream& ostr(std::ostream& lhs) const; }; } // end namespace dial #endif