KIO
kfsprocess.h
Go to the documentation of this file.00001 /* This file is part of the KDE libraries 00002 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at) 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License as published by the Free Software Foundation; either 00007 version 2 of the License, or (at your option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00012 Library General Public License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to 00016 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00017 Boston, MA 02110-1301, USA. 00018 */ 00019 00020 #ifndef KFSPROC_H 00021 #define KFSPROC_H 00022 00023 #include <QtCore/QList> 00024 #include <QtCore/QObject> 00025 00026 #include <sys/types.h> // for pid_t 00027 00028 class QSocketNotifier; 00029 class KfsProcess; 00030 00032 class KfsProcessController : public QObject 00033 { 00034 Q_OBJECT 00035 friend class KfsProcess; 00036 00037 public: 00038 static void theSigCHLDHandler(int signal); 00039 00040 private: 00041 KfsProcessController(); 00042 ~KfsProcessController(); 00043 static void setupHandlers(); 00044 static void resetHandlers(); 00045 static void ref(); 00046 static void deref(); 00047 static KfsProcessController *instance(); 00048 void addKProcess( KfsProcess* ); 00049 void removeKProcess( KfsProcess* ); 00050 void addProcess(int pid); 00051 00052 int m_fd[2]; 00053 QSocketNotifier *m_notifier; 00054 QList<KfsProcess*> m_kProcessList; 00055 QList<int> m_unixProcessList; 00056 static struct sigaction s_oldChildHandlerData; 00057 static bool s_handlerSet; 00058 static int s_refCount; 00059 static KfsProcessController* s_instance; 00060 00061 private Q_SLOTS: 00062 void slotDoHousekeeping(); 00063 }; 00064 00066 class KfsProcess : public QObject 00067 { 00068 Q_OBJECT 00069 friend class KfsProcessController; 00070 00071 public: 00072 00073 explicit KfsProcess( QObject* parent=0L ); 00074 ~KfsProcess(); 00075 00076 KfsProcess &operator<<(const QString& arg); 00077 KfsProcess &operator<<(const char * arg); 00078 bool start(); 00079 void detach(); 00080 00081 Q_SIGNALS: 00082 void processExited(); 00083 00084 private: 00085 QList<QByteArray> arguments; 00086 00087 bool runs; 00088 pid_t pid_; 00089 void processHasExited(); 00090 }; 00091 00092 #endif 00093