process.h00001
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);
00058
00064 void writeLine(const QCString &line, bool addNewline=true);
00065
00071 void unreadLine(const QCString &line, bool addNewline=true);
00072
00077 void setExitString(const QCString &exit) { m_Exit = exit; }
00078
00082 int waitForChild();
00083
00089 int WaitSlave();
00090
00094 int enableLocalEcho(bool enable=true);
00095
00099 void setTerminal(bool terminal) { m_bTerminal = terminal; }
00100
00105 void setErase(bool erase) { m_bErase = erase; }
00106
00110 void setEnvironment( const QCStringList &env );
00111
00115 int fd() {return m_Fd;};
00116
00120 int pid() {return m_Pid;};
00121
00122 public:
00123
00124
00125
00126
00127
00128
00129
00139 static int waitMS(int fd,int ms);
00140
00141
00147 static bool checkPid(pid_t pid);
00148
00156 enum checkPidStatus { Error=-1, NotExited=-2, Killed=-3 } ;
00157 static int checkPidExited(pid_t pid);
00158
00159
00160 protected:
00161 const QCStringList& environment() const;
00162
00163 bool m_bErase, m_bTerminal;
00164 int m_Pid, m_Fd;
00165 QCString m_Command, m_Exit;
00166
00167 private:
00168 int init();
00169 int SetupTTY(int fd);
00170
00171 PTY *m_pPTY;
00172 QCString m_Inbuf, m_TTY;
00173
00174 protected:
00175 virtual void virtual_hook( int id, void* data );
00176 private:
00177 class PtyProcessPrivate;
00178 PtyProcessPrivate *d;
00179 };
00180
00181
00182 #endif
|