kprocctrl.h
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 __KPROCCTRL_H__ 00021 #define __KPROCCTRL_H__ 00022 00023 #include <qvaluelist.h> 00024 00025 #include "kprocess.h" 00026 00027 class QSocketNotifier; 00028 00039 class KDECORE_EXPORT KProcessController : public QObject 00040 { 00041 Q_OBJECT 00042 00043 public: 00048 static void ref(); 00049 00054 static void deref(); 00055 00060 static KProcessController *theKProcessController; // kde4: rename: instance 00061 00069 static void theSigCHLDHandler(int signal); // KDE4: private 00070 00081 bool waitForProcessExit(int timeout); 00082 00088 void unscheduleCheck(); 00089 00095 void rescheduleCheck(); 00096 00097 /* 00098 * Obtain the file descriptor KProcessController uses to get notified 00099 * about process exits. select() or poll() on it if you create a custom 00100 * event loop that needs to act upon SIGCHLD. 00101 * @return the file descriptor of the reading end of the notification pipe 00102 * @since 3.2 00103 */ 00104 int notifierFd() const; 00105 00109 void addKProcess( KProcess* ); 00113 void removeKProcess( KProcess* ); 00117 void addProcess( int pid ); 00118 00119 private slots: 00120 void slotDoHousekeeping(); 00121 00122 private: 00123 friend class I_just_love_gcc; 00124 00125 int fd[2]; 00126 bool needcheck; 00127 QSocketNotifier *notifier; 00128 QValueList<KProcess*> kProcessList; 00129 QValueList<int> unixProcessList; 00130 00131 static void setupHandlers(); 00132 static void resetHandlers(); 00133 static struct sigaction oldChildHandlerData; 00134 static bool handlerSet; 00135 00136 static int refCount; 00137 00138 // Disallow instantiation 00139 KProcessController(); 00140 ~KProcessController(); 00141 00142 // Disallow assignment and copy-construction 00143 KProcessController( const KProcessController& ); 00144 KProcessController& operator= ( const KProcessController& ); 00145 }; 00146 00147 00148 00149 #endif 00150