00001 #ifndef SYSTEM_UNIX_H_ 00002 #define SYSTEM_UNIX_H_ 00003 00004 #include <signal.h> 00005 00006 #include <QWaitCondition> 00007 #include <QBuffer> 00008 #include <QObject> 00009 #include <QMutex> 00010 #include <QList> 00011 #include <QMap> 00012 00013 #include "mythbaseexp.h" 00014 #include "mythsystem.h" 00015 #include "mthread.h" 00016 00017 class MythSystemWindows; 00018 00019 typedef QMap<HANDLE, MythSystemWindows *> MSMap_t; 00020 typedef QMap<HANDLE, QBuffer *> PMap_t; 00021 typedef QList<MythSystemWindows *> MSList_t; 00022 00023 class MythSystemIOHandler: public MThread 00024 { 00025 public: 00026 MythSystemIOHandler(bool read); 00027 ~MythSystemIOHandler() { wait(); } 00028 void run(void); 00029 00030 void insert(HANDLE h, QBuffer *buff); 00031 void remove(HANDLE h); 00032 void wake(); 00033 00034 private: 00035 bool HandleRead(HANDLE h, QBuffer *buff); 00036 bool HandleWrite(HANDLE h, QBuffer *buff); 00037 00038 QMutex m_pWaitLock; 00039 QWaitCondition m_pWait; 00040 QMutex m_pLock; 00041 PMap_t m_pMap; 00042 00043 bool m_read; 00044 char m_readbuf[65536]; 00045 }; 00046 00047 class MythSystemManager : public MThread 00048 { 00049 public: 00050 MythSystemManager(); 00051 ~MythSystemManager(); 00052 void run(void); 00053 void append(MythSystemWindows *); 00054 void jumpAbort(void); 00055 00056 private: 00057 void ChildListRebuild(); 00058 00059 int m_childCount; 00060 HANDLE *m_children; 00061 MSMap_t m_pMap; 00062 QMutex m_mapLock; 00063 00064 bool m_jumpAbort; 00065 QMutex m_jumpLock; 00066 }; 00067 00068 class MythSystemSignalManager : public MThread 00069 { 00070 public: 00071 MythSystemSignalManager(); 00072 ~MythSystemSignalManager() { wait(); } 00073 void run(void); 00074 private: 00075 }; 00076 00077 00078 class MBASE_PUBLIC MythSystemWindows : public MythSystemPrivate 00079 { 00080 Q_OBJECT 00081 00082 public: 00083 MythSystemWindows(MythSystem *parent); 00084 ~MythSystemWindows(); 00085 00086 virtual void Fork(time_t timeout); 00087 virtual void Manage(); 00088 00089 virtual void Term(bool force=false); 00090 virtual void Signal(int sig); 00091 virtual void JumpAbort(void); 00092 00093 virtual bool ParseShell(const QString cmd, QString &abscmd, 00094 QStringList &args); 00095 00096 friend class MythSystemManager; 00097 friend class MythSystemSignalManager; 00098 friend class MythSystemIOHandler; 00099 00100 private: 00101 HANDLE m_child; 00102 time_t m_timeout; 00103 00104 HANDLE m_stdpipe[3]; 00105 }; 00106 00107 #endif 00108 00109 /* 00110 * vim:ts=4:sw=4:ai:et:si:sts=4 00111 */
1.6.3