• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

  • tdecore
tdeprocess.h
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 __TDEPROCESS_H__
21#define __TDEPROCESS_H__
22
23#include <sys/types.h> // for pid_t
24#include <sys/wait.h>
25#include <signal.h>
26#include <unistd.h>
27#include <tqvaluelist.h>
28#include <tqcstring.h>
29#include <tqobject.h>
30#include "tdelibs_export.h"
31
32class TQSocketNotifier;
33class TDEProcessPrivate;
34
35#ifdef Q_OS_UNIX
36#include <kpty.h>
37#else
38class KPty;
39#endif
40
130class TDECORE_EXPORT TDEProcess : public TQObject
131{
132 TQ_OBJECT
133
134public:
135
157 enum Communication {
158 NoCommunication = 0,
159 Stdin = 1, Stdout = 2, Stderr = 4,
160 AllOutput = 6, All = 7,
161 NoRead = 8,
162 CTtyOnly = NoRead,
163 MergedStderr = 16
164 };
165
169 enum RunMode {
174 DontCare,
178 NotifyOnExit,
182 Block,
187 OwnGroup
188 };
189
194 TDEProcess( TQObject* parent, const char *name = 0 );
195 // KDE4 merge with the above
199 TDEProcess();
200
209 virtual ~TDEProcess();
210
222 bool setExecutable(const TQString& proc) TDE_DEPRECATED;
223
224
238 TDEProcess &operator<<(const TQString& arg);
242 TDEProcess &operator<<(const char * arg);
248 TDEProcess &operator<<(const TQCString & arg);
249
256 TDEProcess &operator<<(const TQStringList& args);
257
262 void clearArguments();
263
290 virtual bool start(RunMode runmode = NotifyOnExit,
291 Communication comm = NoCommunication);
292
299 virtual bool kill(int signo = SIGTERM);
300
305 bool isRunning() const;
306
317 pid_t pid() const;
318
323 TDE_DEPRECATED pid_t getPid() const { return pid(); }
324
328 void suspend();
329
333 void resume();
334
343 bool wait(int timeout = -1);
344
351 bool normalExit() const;
352
361 bool signalled() const;
362
372 bool coreDumped() const;
373
380 int exitStatus() const;
381
390 int exitSignal() const;
391
422 bool writeStdin(const char *buffer, int buflen);
423
430 bool closeStdin();
431
439 bool closeStdout();
440
448 bool closeStderr();
449
458 bool closePty();
459
466 void closeAll();
467
472 const TQValueList<TQCString> &args() /* const */ { return arguments; }
473
483 void setRunPrivileged(bool keepPrivileges);
484
490 bool runPrivileged() const;
491
498 void setEnvironment(const TQString &name, const TQString &value);
499
506 void setWorkingDirectory(const TQString &dir);
507
524 void setUseShell(bool useShell, const char *shell = 0);
525
535 static TQString quote(const TQString &arg);
536
544 void detach();
545
546#ifdef Q_OS_UNIX
558 void setUsePty(Communication comm, bool addUtmp);
559
567 KPty *pty() const;
568#endif
569
573 enum { PrioLowest = 20, PrioLow = 10, PrioLower = 5, PrioNormal = 0,
574 PrioHigher = -5, PrioHigh = -10, PrioHighest = -19 };
575
582 bool setPriority(int prio);
583
584signals:
591 void processExited(TDEProcess *proc);
592
593
612 void receivedStdout(TDEProcess *proc, char *buffer, int buflen);
613
632 void receivedStdout(int fd, int &len); // KDE4: change, broken API
633
634
649 void receivedStderr(TDEProcess *proc, char *buffer, int buflen);
650
657 void wroteStdin(TDEProcess *proc);
658
659
660protected slots:
661
667 void slotChildOutput(int fdno);
668
674 void slotChildError(int fdno);
675
682 void slotSendData(int dummy); // KDE 4: remove dummy
683
684protected:
685
690 void setupEnvironment();
691
696 TQValueList<TQCString> arguments;
701 RunMode run_mode;
708 bool runs;
709
717 pid_t pid_;
718
726 int status;
727
728
734 bool keepPrivs;
735
748 virtual int setupCommunication(Communication comm);
749
762 virtual int commSetupDoneP();
763
769 virtual int commSetupDoneC();
770
771
778 virtual void processHasExited(int state);
779
805 virtual void commClose();
806
807 /* KDE 4 - commClose will be changed to perform cleanup only in all cases *
808 * If @p notfd is -1, all data immediately available from the
809 * communication links should be processed.
810 * If @p notfd is not -1, the communication links should be monitored
811 * for data until the file handle @p notfd becomes ready for reading.
812 */
813// virtual void commDrain(int notfd);
814
820 void setBinaryExecutable(const char *filename);
821
825 int out[2];
829 int in[2];
833 int err[2];
834
838 TQSocketNotifier *innot;
842 TQSocketNotifier *outnot;
846 TQSocketNotifier *errnot;
847
852 Communication communication;
853
859 int childOutput(int fdno);
860
866 int childError(int fdno);
867
871 const char *input_data;
875 int input_sent;
879 int input_total;
880
885 friend class TDEProcessController;
886
887protected:
888 virtual void virtual_hook( int id, void* data );
889private:
890 TDEProcessPrivate *d;
891};
892
893class KShellProcessPrivate;
894
904class TDECORE_EXPORT KShellProcess: public TDEProcess
905{
906 TQ_OBJECT
907
908public:
909
915 KShellProcess(const char *shellname=0);
916
920 ~KShellProcess();
921
922 virtual bool start(RunMode runmode = NotifyOnExit,
923 Communication comm = NoCommunication);
924
925 static TQString quote(const TQString &arg);
926
927private:
928 TQCString shell;
929
930protected:
931 virtual void virtual_hook( int id, void* data );
932private:
933 KShellProcessPrivate *d;
934};
935
936#endif
KPty
Provides a high level representation of a pseudo tty pair, including utmp support.
Definition: kpty.h:40
KShellProcess
A class derived from TDEProcess to start child processes through a shell.
Definition: tdeprocess.h:905
TDEProcessController
Used internally by TDEProcess.
Definition: tdeprocctrl.h:40
TDEProcess
Child process invocation, monitoring and control.
Definition: tdeprocess.h:131
TDEProcess::status
int status
The process' exit status as returned by waitpid().
Definition: tdeprocess.h:726
TDEProcess::pid_
pid_t pid_
The PID of the currently running process.
Definition: tdeprocess.h:717
TDEProcess::outnot
TQSocketNotifier * outnot
The socket notifier for out[0].
Definition: tdeprocess.h:842
TDEProcess::args
const TQValueList< TQCString > & args()
Lets you see what your arguments are for debugging.
Definition: tdeprocess.h:472
TDEProcess::communication
Communication communication
Lists the communication links that are activated for the child process.
Definition: tdeprocess.h:852
TDEProcess::runs
bool runs
true if the process is currently running.
Definition: tdeprocess.h:708
TDEProcess::input_sent
int input_sent
The number of bytes already transmitted.
Definition: tdeprocess.h:875
TDEProcess::getPid
TDE_DEPRECATED pid_t getPid() const
Definition: tdeprocess.h:323
TDEProcess::processExited
void processExited(TDEProcess *proc)
Emitted after the process has terminated when the process was run in the NotifyOnExit (==default opti...
TDEProcess::keepPrivs
bool keepPrivs
If false, the child process' effective uid & gid will be reset to the real values.
Definition: tdeprocess.h:734
TDEProcess::RunMode
RunMode
Run-modes for a child process.
Definition: tdeprocess.h:169
TDEProcess::DontCare
@ DontCare
The application does not receive notifications from the subprocess when it is finished or aborted.
Definition: tdeprocess.h:174
TDEProcess::NotifyOnExit
@ NotifyOnExit
The application is notified when the subprocess dies.
Definition: tdeprocess.h:178
TDEProcess::Block
@ Block
The application is suspended until the started process is finished.
Definition: tdeprocess.h:182
TDEProcess::Communication
Communication
Modes in which the communication channel can be opened.
Definition: tdeprocess.h:157
TDEProcess::arguments
TQValueList< TQCString > arguments
The list of the process' command line arguments.
Definition: tdeprocess.h:696
TDEProcess::run_mode
RunMode run_mode
How to run the process (Block, NotifyOnExit, DontCare).
Definition: tdeprocess.h:701
TDEProcess::input_total
int input_total
The total length of input_data.
Definition: tdeprocess.h:879
TDEProcess::receivedStdout
void receivedStdout(int fd, int &len)
Emitted when output from the child process has been received on stdout.
TDEProcess::errnot
TQSocketNotifier * errnot
The socket notifier for err[0].
Definition: tdeprocess.h:846
TDEProcess::innot
TQSocketNotifier * innot
The socket notifier for in[1].
Definition: tdeprocess.h:838
TDEProcess::input_data
const char * input_data
The buffer holding the data that has to be sent to the child.
Definition: tdeprocess.h:871
TDEProcess::receivedStderr
void receivedStderr(TDEProcess *proc, char *buffer, int buflen)
Emitted, when output from the child process has been received on stderr.
TDEProcess::wroteStdin
void wroteStdin(TDEProcess *proc)
Emitted after all the data that has been specified by a prior call to writeStdin() has actually been ...
TDEProcess::receivedStdout
void receivedStdout(TDEProcess *proc, char *buffer, int buflen)
Emitted, when output from the child process has been received on stdout.

tdecore

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

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.9.4
This website is maintained by Timothy Pearson.