00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 #ifndef Process_h
00030 #define Process_h
00031
00032 #include <y2util/ExternalProgram.h>
00033
00041 class Process: public ExternalProgram
00042 {
00043
00044 private:
00045
00046 std::string stdout_buffer;
00047 std::string stderr_buffer;
00048
00049 FILE *stderr_output;
00050
00051 private:
00052
00053
00054 Process(const Process&);
00055 Process& operator=(const Process&);
00056
00057
00058 int create_stderr_pipes();
00059
00060
00061 std::string GetLineFromBuffer(std::string &buffer);
00062
00063
00064
00065 void BufferNewStdoutLines();
00066
00067
00068 bool IsAnyLineInBuffer(const std::string &buffer);
00069
00070 public:
00071
00080 Process(const std::string &commandline, bool use_pty = false, bool default_locale = false, bool pty_trans = true)
00081 : ExternalProgram(commandline, Stderr_To_FileDesc,
00082 use_pty, create_stderr_pipes(), default_locale, "", pty_trans), stderr_output(NULL)
00083 {}
00084
00091 Process(const char *const *argv, const Environment &environment, bool use_pty = false, bool default_locale = false, bool pty_trans = true)
00092 : ExternalProgram(argv, environment, Stderr_To_FileDesc,
00093 use_pty, create_stderr_pipes(), default_locale, "", pty_trans)
00094 {}
00095
00096
00097 ~Process();
00098
00102 bool kill(int sig);
00103
00107 bool kill();
00108
00112 std::string readLine();
00113
00117 std::string read();
00118
00122 std::string readErrLine();
00123
00127 std::string readErr();
00128
00132 int closeAll();
00133
00137 void readStdoutToBuffer();
00138
00142 void readStderrToBuffer();
00143
00147 bool anyLineInStdout();
00148
00152 FILE* errorFile();
00153
00154 };
00155
00156 #endif // Process_h