• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdelibs-4.14.38 API Reference
  • KDE Home
  • Contact Us
 

KDE3Support

  • kde3support
  • kdecore
k3process.h
Go to the documentation of this file.
1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Christian Czezakte (e9025461@student.tuwien.ac.at)
3
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version.
8
9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
13
14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 Boston, MA 02110-1301, USA.
18*/
19
20#ifndef K3PROCESS_H
21#define K3PROCESS_H
22
23#include <kde3support_export.h>
24
25#include <QtCore/QObject>
26
27#include <sys/types.h> // for pid_t
28#include <sys/wait.h>
29#include <signal.h>
30#include <unistd.h>
31
32class QSocketNotifier;
33class K3ProcessPrivate;
34class KPty;
35
127class KDE3SUPPORT_EXPORT_DEPRECATED K3Process : public QObject
128{
129 Q_OBJECT
130
131public:
132
142 enum CommunicationFlag {
143 NoCommunication = 0,
144 Stdin = 1,
145 Stdout = 2,
146 Stderr = 4,
147 AllOutput = 6,
148 All = 7,
149 NoRead = 8,
151 CTtyOnly = NoRead,
154 MergedStderr = 16
158 };
159
160 Q_DECLARE_FLAGS(Communication, CommunicationFlag)
161
162
165 enum RunMode {
170 DontCare,
174 NotifyOnExit,
178 Block,
183 OwnGroup
184 };
185
189 explicit K3Process( QObject* parent=0L );
190
199 virtual ~K3Process();
200
214 K3Process &operator<<(const QString& arg);
218 K3Process &operator<<(const char * arg);
224 K3Process &operator<<(const QByteArray & arg);
225
232 K3Process &operator<<(const QStringList& args);
233
238 void clearArguments();
239
266 virtual bool start(RunMode runmode = NotifyOnExit,
267 Communication comm = NoCommunication);
268
275 virtual bool kill(int signo = SIGTERM);
276
281 bool isRunning() const;
282
293 pid_t pid() const;
294
298 void suspend();
299
303 void resume();
304
312 bool wait(int timeout = -1);
313
320 bool normalExit() const;
321
328 bool signalled() const;
329
337 bool coreDumped() const;
338
345 int exitStatus() const;
346
353 int exitSignal() const;
354
385 bool writeStdin(const char *buffer, int buflen);
386
393 bool closeStdin();
394
402 bool closeStdout();
403
411 bool closeStderr();
412
421 bool closePty();
422
429 void closeAll();
430
435 const QList<QByteArray> &args() /* const */ { return arguments; }
436
446 void setRunPrivileged(bool keepPrivileges);
447
453 bool runPrivileged() const;
454
461 void setEnvironment(const QString &name, const QString &value);
462
469 void setWorkingDirectory(const QString &dir);
470
486 void setUseShell(bool useShell, const char *shell = 0);
487
496 static QString quote(const QString &arg);
497
505 void detach();
506
517 void setUsePty(Communication comm, bool addUtmp);
518
525 KPty *pty() const;
526
530 enum { PrioLowest = 20, PrioLow = 10, PrioLower = 5, PrioNormal = 0,
531 PrioHigher = -5, PrioHigh = -10, PrioHighest = -19 };
532
538 bool setPriority(int prio);
539
540Q_SIGNALS:
547 void processExited(K3Process *proc);
548
549
568 void receivedStdout(K3Process *proc, char *buffer, int buflen);
569
588 void receivedStdout(int fd, int &len); // KDE4: change, broken API
589
590
605 void receivedStderr(K3Process *proc, char *buffer, int buflen);
606
613 void wroteStdin(K3Process *proc);
614
615
616protected Q_SLOTS:
617
623 void slotChildOutput(int fdno);
624
630 void slotChildError(int fdno);
631
638 void slotSendData(int dummy); // KDE 4: remove dummy
639
640protected:
641
646 void setupEnvironment();
647
652 QList<QByteArray> arguments;
657 RunMode run_mode;
664 bool runs;
665
673 pid_t pid_;
674
682 int status;
683
684
690 bool keepPrivs;
691
704 virtual int setupCommunication(Communication comm);
705
718 virtual int commSetupDoneP();
719
725 virtual int commSetupDoneC();
726
727
734 virtual void processHasExited(int state);
735
761 virtual void commClose();
762
763 /* KDE 4 - commClose will be changed to perform cleanup only in all cases *
764 * If @p notfd is -1, all data immediately available from the
765 * communication links should be processed.
766 * If @p notfd is not -1, the communication links should be monitored
767 * for data until the file handle @p notfd becomes ready for reading.
768 */
769// virtual void commDrain(int notfd);
770
776 void setBinaryExecutable(const char *filename);
777
781 int out[2];
785 int in[2];
789 int err[2];
790
794 QSocketNotifier *innot;
798 QSocketNotifier *outnot;
802 QSocketNotifier *errnot;
803
808 Communication communication;
809
815 int childOutput(int fdno);
816
822 int childError(int fdno);
823
827 const char *input_data;
831 int input_sent;
835 int input_total;
836
841 friend class K3ProcessController;
842
843private:
844 K3ProcessPrivate* const d;
845};
846
847Q_DECLARE_OPERATORS_FOR_FLAGS(K3Process::Communication)
848
849class K3ShellProcessPrivate;
850
860class KDE3SUPPORT_EXPORT_DEPRECATED K3ShellProcess : public K3Process
861{
862 Q_OBJECT
863
864public:
865
871 explicit K3ShellProcess(const char *shellname=0);
872
876 ~K3ShellProcess();
877
878 virtual bool start(RunMode runmode = NotifyOnExit,
879 Communication comm = NoCommunication);
880
881 static QString quote(const QString &arg);
882
883private:
884 K3ShellProcessPrivate* const d;
885};
886
887
888
889#endif
890
K3ProcessController
Used internally by K3Process.
Definition: k3processcontroller.h:38
K3Process
Definition: k3process.h:128
K3Process::wroteStdin
void wroteStdin(K3Process *proc)
Emitted after all the data that has been specified by a prior call to writeStdin() has actually been ...
K3Process::keepPrivs
bool keepPrivs
If false, the child process' effective uid & gid will be reset to the real values.
Definition: k3process.h:690
K3Process::arguments
QList< QByteArray > arguments
The list of the process' command line arguments.
Definition: k3process.h:652
K3Process::receivedStdout
void receivedStdout(K3Process *proc, char *buffer, int buflen)
Emitted, when output from the child process has been received on stdout.
K3Process::RunMode
RunMode
Run-modes for a child process.
Definition: k3process.h:165
K3Process::DontCare
@ DontCare
The application does not receive notifications from the subprocess when it is finished or aborted.
Definition: k3process.h:170
K3Process::NotifyOnExit
@ NotifyOnExit
The application is notified when the subprocess dies.
Definition: k3process.h:174
K3Process::Block
@ Block
The application is suspended until the started process is finished.
Definition: k3process.h:178
K3Process::processExited
void processExited(K3Process *proc)
Emitted after the process has terminated when the process was run in the NotifyOnExit (==default opti...
K3Process::runs
bool runs
true if the process is currently running.
Definition: k3process.h:664
K3Process::CommunicationFlag
CommunicationFlag
Modes in which the communication channels can be opened.
Definition: k3process.h:142
K3Process::errnot
QSocketNotifier * errnot
The socket notifier for err[0].
Definition: k3process.h:802
K3Process::input_total
int input_total
The total length of input_data.
Definition: k3process.h:835
K3Process::receivedStdout
void receivedStdout(int fd, int &len)
Emitted when output from the child process has been received on stdout.
K3Process::communication
Communication communication
Lists the communication links that are activated for the child process.
Definition: k3process.h:808
K3Process::pid_
pid_t pid_
The PID of the currently running process.
Definition: k3process.h:673
K3Process::input_sent
int input_sent
The number of bytes already transmitted.
Definition: k3process.h:831
K3Process::input_data
const char * input_data
The buffer holding the data that has to be sent to the child.
Definition: k3process.h:827
K3Process::args
const QList< QByteArray > & args()
Lets you see what your arguments are for debugging.
Definition: k3process.h:435
K3Process::receivedStderr
void receivedStderr(K3Process *proc, char *buffer, int buflen)
Emitted, when output from the child process has been received on stderr.
K3Process::innot
QSocketNotifier * innot
The socket notifier for in[1].
Definition: k3process.h:794
K3Process::run_mode
RunMode run_mode
How to run the process (Block, NotifyOnExit, DontCare).
Definition: k3process.h:657
K3Process::outnot
QSocketNotifier * outnot
The socket notifier for out[0].
Definition: k3process.h:798
K3Process::status
int status
The process' exit status as returned by waitpid().
Definition: k3process.h:682
K3ShellProcess
A class derived from K3Process to start child processes through a shell.
Definition: k3process.h:861
QList
QObject
dummy
static int dummy
Definition: k3syntaxhighlighter.cpp:41
kde3support_export.h
operator<<
QDataStream & operator<<(QDataStream &d, const ActionReply &reply)
This file is part of the KDE documentation.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Mon Feb 20 2023 00:00:00 by doxygen 1.9.6 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDE3Support

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

kdelibs-4.14.38 API Reference

Skip menu "kdelibs-4.14.38 API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal