KDEsu
process.h
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef __Process_h_Included__
00014 #define __Process_h_Included__
00015
00016 #include <sys/types.h>
00017
00018 #include <qcstring.h>
00019 #include <qstring.h>
00020 #include <qstringlist.h>
00021 #include <qvaluelist.h>
00022
00023 #include <kdelibs_export.h>
00024
00025 class PTY;
00026 typedef QValueList<QCString> QCStringList;
00027
00036 class KDESU_EXPORT PtyProcess
00037 {
00038 public:
00039 PtyProcess();
00040 virtual ~PtyProcess();
00041
00049 int exec(const QCString &command, const QCStringList &args);
00050
00057 QCString readLine(bool block=true);
00063 QCString readAll(bool block=true);
00064
00070 void writeLine(const QCString &line, bool addNewline=true);
00071
00077 void unreadLine(const QCString &line, bool addNewline=true);
00078
00083 void setExitString(const QCString &exit) { m_Exit = exit; }
00084
00088 int waitForChild();
00089
00095 int WaitSlave();
00096
00100 int enableLocalEcho(bool enable=true);
00101
00105 void setTerminal(bool terminal) { m_bTerminal = terminal; }
00106
00111 void setErase(bool erase) { m_bErase = erase; }
00112
00116 void setEnvironment( const QCStringList &env );
00117
00121 int fd() {return m_Fd;}
00122
00126 int pid() {return m_Pid;}
00127
00128 public:
00129
00130
00131
00132
00133
00134
00135
00145 static int waitMS(int fd,int ms);
00146
00147
00153 static bool checkPid(pid_t pid);
00154
00162 enum checkPidStatus { Error=-1, NotExited=-2, Killed=-3 } ;
00163 static int checkPidExited(pid_t pid);
00164
00165
00166 protected:
00167 const QCStringList& environment() const;
00168
00169 bool m_bErase, m_bTerminal;
00170 int m_Pid, m_Fd;
00171 QCString m_Command, m_Exit;
00172
00173 private:
00174 int init();
00175 int SetupTTY(int fd);
00176
00177 PTY *m_pPTY;
00178 QCString m_Inbuf, m_TTY;
00179
00180 protected:
00181 virtual void virtual_hook( int id, void* data );
00182 private:
00183 class PtyProcessPrivate;
00184 PtyProcessPrivate *d;
00185 };
00186
00187
00188 #endif