• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

KDECore

kprocess.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 __kprocess_h__
00021 #define __kprocess_h__
00022 
00023 #include <sys/types.h> // for pid_t
00024 #include <sys/wait.h>
00025 #include <signal.h>
00026 #include <unistd.h>
00027 #include <qvaluelist.h>
00028 #include <qcstring.h>
00029 #include <qobject.h>
00030 #include "kdelibs_export.h"
00031 
00032 class QSocketNotifier;
00033 class KProcessPrivate;
00034 class KPty;
00035 
00125 class KDECORE_EXPORT KProcess : public QObject
00126 {
00127   Q_OBJECT
00128 
00129 public:
00130 
00152   enum Communication {
00153        NoCommunication = 0,
00154        Stdin = 1, Stdout = 2, Stderr = 4,
00155        AllOutput = 6, All = 7,
00156        NoRead = 8,
00157        CTtyOnly = NoRead,
00158        MergedStderr = 16
00159   };
00160 
00164   enum RunMode {
00169        DontCare,
00173        NotifyOnExit,
00177        Block,
00182        OwnGroup
00183   };
00184 
00189   KProcess( QObject* parent, const char *name = 0 );
00190  // KDE4 merge with the above
00194   KProcess();
00195 
00204   virtual ~KProcess();
00205 
00217   bool setExecutable(const QString& proc) KDE_DEPRECATED;
00218 
00219 
00233   KProcess &operator<<(const QString& arg);
00237   KProcess &operator<<(const char * arg);
00243   KProcess &operator<<(const QCString & arg);
00244 
00251   KProcess &operator<<(const QStringList& args);
00252 
00257   void clearArguments();
00258 
00285   virtual bool start(RunMode  runmode = NotifyOnExit,
00286     Communication comm = NoCommunication);
00287 
00294   virtual bool kill(int signo = SIGTERM);
00295 
00300   bool isRunning() const;
00301 
00312   pid_t pid() const;
00313 
00318   KDE_DEPRECATED pid_t getPid() const { return pid(); }
00319 
00323   void suspend();
00324 
00328   void resume();
00329 
00338   bool wait(int timeout = -1);
00339 
00346   bool normalExit() const;
00347 
00356   bool signalled() const;
00357 
00367   bool coreDumped() const;
00368 
00375   int exitStatus() const;
00376 
00385   int exitSignal() const;
00386 
00417   bool writeStdin(const char *buffer, int buflen);
00418 
00425   bool closeStdin();
00426 
00434   bool closeStdout();
00435 
00443   bool closeStderr();
00444 
00453   bool closePty();
00454 
00461   void closeAll();
00462 
00467   const QValueList<QCString> &args() /* const */ { return arguments; }
00468 
00478   void setRunPrivileged(bool keepPrivileges);
00479 
00485   bool runPrivileged() const;
00486 
00493   void setEnvironment(const QString &name, const QString &value);
00494 
00501   void setWorkingDirectory(const QString &dir);
00502 
00519   void setUseShell(bool useShell, const char *shell = 0);
00520 
00530   static QString quote(const QString &arg);
00531 
00539   void detach();
00540 
00541 #ifdef Q_OS_UNIX
00542 
00553   void setUsePty(Communication comm, bool addUtmp);
00554 
00562   KPty *pty() const;
00563 #endif
00564 
00568   enum { PrioLowest = 20, PrioLow = 10, PrioLower = 5, PrioNormal = 0,
00569     PrioHigher = -5, PrioHigh = -10, PrioHighest = -19 };
00570 
00577   bool setPriority(int prio);
00578 
00579 signals:
00586   void processExited(KProcess *proc);
00587 
00588 
00607   void receivedStdout(KProcess *proc, char *buffer, int buflen);
00608 
00627   void receivedStdout(int fd, int &len); // KDE4: change, broken API
00628 
00629 
00644   void receivedStderr(KProcess *proc, char *buffer, int buflen);
00645 
00652   void wroteStdin(KProcess *proc);
00653 
00654 
00655 protected slots:
00656 
00662   void slotChildOutput(int fdno);
00663 
00669   void slotChildError(int fdno);
00670 
00677   void slotSendData(int dummy); // KDE 4: remove dummy
00678 
00679 protected:
00680 
00685   void setupEnvironment();
00686 
00691   QValueList<QCString> arguments;
00696   RunMode run_mode;
00703   bool runs;
00704 
00712   pid_t pid_;
00713 
00721   int status;
00722 
00723 
00729   bool keepPrivs;
00730 
00743   virtual int setupCommunication(Communication comm);
00744 
00757   virtual int commSetupDoneP();
00758 
00764   virtual int commSetupDoneC();
00765 
00766 
00773   virtual void processHasExited(int state);
00774 
00800   virtual void commClose();
00801 
00802   /* KDE 4 - commClose will be changed to perform cleanup only in all cases *
00803    * If @p notfd is -1, all data immediately available from the
00804    *  communication links should be processed.
00805    * If @p notfd is not -1, the communication links should be monitored
00806    *  for data until the file handle @p notfd becomes ready for reading.
00807    */
00808 //  virtual void commDrain(int notfd);
00809 
00815   void setBinaryExecutable(const char *filename);
00816 
00820   int out[2];
00824   int in[2];
00828   int err[2];
00829 
00833   QSocketNotifier *innot;
00837   QSocketNotifier *outnot;
00841   QSocketNotifier *errnot;
00842 
00847   Communication communication;
00848 
00854   int childOutput(int fdno);
00855 
00861   int childError(int fdno);
00862 
00866   const char *input_data;
00870   int input_sent;
00874   int input_total;
00875 
00880   friend class KProcessController;
00881 
00882 protected:
00883   virtual void virtual_hook( int id, void* data );
00884 private:
00885   KProcessPrivate *d;
00886 };
00887 
00888 class KShellProcessPrivate;
00889 
00899 class KDECORE_EXPORT KShellProcess: public KProcess
00900 {
00901   Q_OBJECT
00902 
00903 public:
00904 
00910   KShellProcess(const char *shellname=0);
00911 
00915   ~KShellProcess();
00916 
00917   virtual bool start(RunMode  runmode = NotifyOnExit,
00918           Communication comm = NoCommunication);
00919 
00920   static QString quote(const QString &arg);
00921 
00922 private:
00923   QCString shell;
00924 
00925 protected:
00926   virtual void virtual_hook( int id, void* data );
00927 private:
00928   KShellProcessPrivate *d;
00929 };
00930 
00931 
00932 
00933 #endif
00934 

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal