00001 #ifndef PROCESS_H
00002 #define PROCESS_H
00003 #include <map>
00004 #include <string>
00005 #include <sys/types.h>
00006
00012 class Process
00013 {
00014 int pipes[3][2];
00015
00016 fd_set sock_set;
00017 int last_socket_read;
00018 std::map<int, int> output_sock_list;
00019
00020 protected:
00021 int exit_code;
00022 pid_t pid;
00023
00030 virtual std::string ParentOnFork() { return std::string(""); }
00031
00038 virtual std::string ChildOnFork() { return std::string(""); }
00039
00047 virtual std::string HandleEvents();
00048
00049 public:
00050
00051 Process();
00052 virtual ~Process();
00053
00062 std::string Start(char* file, char** argv);
00063
00068 std::string Fork();
00069
00074 int GetPID();
00075
00079 int GetExitCode();
00080
00093 std::string GetOutput(char* buf, unsigned int& len, int& fd);
00094
00102 std::string SendStdin(char* buf, int len);
00103
00108 void SendStdinClose();
00109 };
00110
00111 #endif
00112