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
00030 #ifndef Process_h
00031 #define Process_h
00032
00033 #include <y2util/ExternalProgram.h>
00034
00042 class Process: public ExternalProgram
00043 {
00044
00045 private:
00046
00047 std::string stdout_buffer;
00048 std::string stderr_buffer;
00049
00050 FILE *stderr_output;
00051
00052 private:
00053
00054
00055 Process(const Process&);
00056 Process& operator=(const Process&);
00057
00058
00059 int create_stderr_pipes();
00060
00061
00062 std::string GetLineFromBuffer(std::string &buffer);
00063
00064
00065
00066 void BufferNewStdoutLines();
00067
00068
00069 bool IsAnyLineInBuffer(const std::string &buffer);
00070
00071 public:
00072
00081 Process(const std::string &commandline, bool use_pty = false, bool default_locale = false, bool pty_trans = true)
00082 : ExternalProgram(commandline, Stderr_To_FileDesc,
00083 use_pty, create_stderr_pipes(), default_locale, "", pty_trans), stderr_output(NULL)
00084 {}
00085
00092 Process(const char *const *argv, const Environment &environment, bool use_pty = false, bool default_locale = false, bool pty_trans = true)
00093 : ExternalProgram(argv, environment, Stderr_To_FileDesc,
00094 use_pty, create_stderr_pipes(), default_locale, "", pty_trans)
00095 {}
00096
00097
00098 ~Process();
00099
00103 bool kill(int sig);
00104
00108 bool kill();
00109
00113 std::string readLine();
00114
00118 std::string read();
00119
00123 std::string readErrLine();
00124
00128 std::string readErr();
00129
00133 int closeAll();
00134
00138 void readStdoutToBuffer();
00139
00143 void readStderrToBuffer();
00144
00148 bool anyLineInStdout();
00149
00153 FILE* errorFile();
00154
00155 };
00156
00157 #endif // Process_h