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

tdecore

Public Types | Signals | Public Member Functions | Static Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | Friends | List of all members
TDEProcess Class Reference

#include <tdeprocess.h>

Inheritance diagram for TDEProcess:
KShellProcess TDEProcIO

Public Types

enum  Communication {
  NoCommunication = 0 , Stdin = 1 , Stdout = 2 , Stderr = 4 ,
  AllOutput = 6 , All = 7 , NoRead = 8 , CTtyOnly = NoRead ,
  MergedStderr = 16
}
 
enum  RunMode { DontCare , NotifyOnExit , Block , OwnGroup }
 
enum  {
  PrioLowest = 20 , PrioLow = 10 , PrioLower = 5 , PrioNormal = 0 ,
  PrioHigher = -5 , PrioHigh = -10 , PrioHighest = -19
}
 

Signals

void processExited (TDEProcess *proc)
 
void receivedStdout (TDEProcess *proc, char *buffer, int buflen)
 
void receivedStdout (int fd, int &len)
 
void receivedStderr (TDEProcess *proc, char *buffer, int buflen)
 
void wroteStdin (TDEProcess *proc)
 

Public Member Functions

 TDEProcess (TQObject *parent, const char *name=0)
 
 TDEProcess ()
 
virtual ~TDEProcess ()
 
bool setExecutable (const TQString &proc) TDE_DEPRECATED
 
TDEProcess & operator<< (const TQString &arg)
 
TDEProcess & operator<< (const char *arg)
 
TDEProcess & operator<< (const TQCString &arg)
 
TDEProcess & operator<< (const TQStringList &args)
 
void clearArguments ()
 
virtual bool start (RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
 
virtual bool kill (int signo=SIGTERM)
 
bool isRunning () const
 
pid_t pid () const
 
TDE_DEPRECATED pid_t getPid () const
 
void suspend ()
 
void resume ()
 
bool wait (int timeout=-1)
 
bool normalExit () const
 
bool signalled () const
 
bool coreDumped () const
 
int exitStatus () const
 
int exitSignal () const
 
bool writeStdin (const char *buffer, int buflen)
 
bool closeStdin ()
 
bool closeStdout ()
 
bool closeStderr ()
 
bool closePty ()
 
void closeAll ()
 
const TQValueList< TQCString > & args ()
 
void setRunPrivileged (bool keepPrivileges)
 
bool runPrivileged () const
 
void setEnvironment (const TQString &name, const TQString &value)
 
void setWorkingDirectory (const TQString &dir)
 
void setUseShell (bool useShell, const char *shell=0)
 
void detach ()
 
void setUsePty (Communication comm, bool addUtmp)
 
KPty * pty () const
 
bool setPriority (int prio)
 

Static Public Member Functions

static TQString quote (const TQString &arg)
 

Protected Slots

void slotChildOutput (int fdno)
 
void slotChildError (int fdno)
 
void slotSendData (int dummy)
 

Protected Member Functions

void setupEnvironment ()
 
virtual int setupCommunication (Communication comm)
 
virtual int commSetupDoneP ()
 
virtual int commSetupDoneC ()
 
virtual void processHasExited (int state)
 
virtual void commClose ()
 
void setBinaryExecutable (const char *filename)
 
int childOutput (int fdno)
 
int childError (int fdno)
 
virtual void virtual_hook (int id, void *data)
 

Protected Attributes

TQValueList< TQCString > arguments
 
RunMode run_mode
 
bool runs
 
pid_t pid_
 
int status
 
bool keepPrivs
 
int out [2]
 
int in [2]
 
int err [2]
 
TQSocketNotifier * innot
 
TQSocketNotifier * outnot
 
TQSocketNotifier * errnot
 
Communication communication
 
const char * input_data
 
int input_sent
 
int input_total
 

Friends

class TDEProcessController
 

Detailed Description

Child process invocation, monitoring and control.

This class works only in the application's main thread.

General usage and features:
This class allows a KDE application to start child processes without having to worry about UN*X signal handling issues and zombie process reaping.

See also
TDEProcIO

Basically, this class distinguishes three different ways of running child processes:

  • DontCare – The child process is invoked and both the child process and the parent process continue concurrently.

The process is started in an own session (see setsid(2)).

  • NotifyOnExit – The child process is invoked and both the child and the parent process run concurrently.

When the child process exits, the TDEProcess instance corresponding to it emits the Qt signal processExited(). Since this signal is not emitted from within a UN*X signal handler, arbitrary function calls can be made.

Be aware: When the TDEProcess object gets destructed, the child process will be killed if it is still running! This means in particular, that it usually makes no sense to use a TDEProcess on the stack with NotifyOnExit.

  • OwnGroup – like NotifyOnExit, but the child process is started in an own process group (and an own session, FWIW). The behavior of kill() changes to killing the whole process group - this makes this mode useful for implementing primitive job management. It can be used to work around broken wrapper scripts that don't propagate signals to the "real" program. However, use this with care, as you disturb the shell's job management if your program is started from the command line.
  • Block – The child process starts and the parent process is suspended until the child process exits. (Really not recommended for programs with a GUI.) In this mode the parent can read the child's output, but can't send it any input.

TDEProcess also provides several functions for determining the exit status and the pid of the child process it represents.

Furthermore it is possible to supply command-line arguments to the process in a clean fashion (no null-terminated stringlists and such...)

A small usage example:

TDEProcess *proc = new TDEProcess;
*proc << "my_executable";
*proc << "These" << "are" << "the" << "command" << "line" << "args";
TQApplication::connect(proc, TQ_SIGNAL(processExited(TDEProcess *)),
pointer_to_my_object, TQ_SLOT(my_objects_slot(TDEProcess *)));
proc->start();
TDEProcess
Child process invocation, monitoring and control.
Definition: tdeprocess.h:131
TDEProcess::TDEProcess
TDEProcess()
Constructor.
Definition: tdeprocess.cpp:140
TDEProcess::start
virtual bool start(RunMode runmode=NotifyOnExit, Communication comm=NoCommunication)
Starts the process.
Definition: tdeprocess.cpp:293
TDEProcess::processExited
void processExited(TDEProcess *proc)
Emitted after the process has terminated when the process was run in the NotifyOnExit (==default opti...

This will start "my_executable" with the commandline arguments "These"...

When the child process exits, the slot will be invoked.

Communication with the child process:
TDEProcess supports communication with the child process through stdin/stdout/stderr.

The following functions are provided for getting data from the child process or sending data to the child's stdin (For more information, have a look at the documentation of each function):

  • writeStdin() – Transmit data to the child process' stdin. When all data was sent, the signal wroteStdin() is emitted.
  • When data arrives at stdout or stderr, the signal receivedStdout() resp. receivedStderr() is emitted.
  • You can shut down individual communication channels with closeStdin(), closeStdout(), and closeStderr(), resp.
Author
Christian Czezatke e9025.nosp@m.461@.nosp@m.stude.nosp@m.nt.t.nosp@m.uwien.nosp@m..ac..nosp@m.at

Definition at line 130 of file tdeprocess.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

More or less intuitive constants for use with setPriority().

Definition at line 573 of file tdeprocess.h.

◆ Communication

enum TDEProcess::Communication

Modes in which the communication channel can be opened.

If communication for more than one channel is required, the values have to be or'ed together, for example to get communication with stdout as well as with stdin, you would specify Stdin | Stdout

If NoRead is specified in conjunction with Stdout, no data is actually read from Stdout but only the signal receivedStdout(int fd, int &len) is emitted.

CTtyOnly tells setUsePty() to create a PTY for the process and make it the process' controlling TTY, but does not redirect any I/O channel to the PTY.

If MergedStderr is specified in conjunction with Stdout, Stderr will be redirected onto the same file handle as Stdout, i.e., all error output will be signalled with receivedStdout(). Don't specify Stderr if you specify MergedStderr.

Definition at line 157 of file tdeprocess.h.

◆ RunMode

enum TDEProcess::RunMode

Run-modes for a child process.

Enumerator
DontCare 

The application does not receive notifications from the subprocess when it is finished or aborted.

NotifyOnExit 

The application is notified when the subprocess dies.

Block 

The application is suspended until the started process is finished.

OwnGroup 

Same as NotifyOnExit, but the process is run in an own session, just like with DontCare.

Definition at line 169 of file tdeprocess.h.

Constructor & Destructor Documentation

◆ TDEProcess() [1/2]

TDEProcess::TDEProcess ( TQObject *  parent,
const char *  name = 0 
)

Constructor.

Since
3.2

Definition at line 115 of file tdeprocess.cpp.

◆ TDEProcess() [2/2]

TDEProcess::TDEProcess ( )

Constructor.

Definition at line 140 of file tdeprocess.cpp.

◆ ~TDEProcess()

TDEProcess::~TDEProcess ( )
virtual

Destructor:

If the process is running when the destructor for this class is called, the child process is killed with a SIGKILL, but only if the run mode is not of type DontCare. Processes started as DontCare keep running anyway.

Definition at line 220 of file tdeprocess.cpp.

Member Function Documentation

◆ args()

const TQValueList< TQCString > & TDEProcess::args ( )
inline

Lets you see what your arguments are for debugging.

Returns
the list of arguments

Definition at line 472 of file tdeprocess.h.

◆ childError()

int TDEProcess::childError ( int  fdno)
protected

Called by slotChildError() this function copies data arriving from the child process' stderr to the respective buffer and emits the signal receivedStderr().

Definition at line 854 of file tdeprocess.cpp.

◆ childOutput()

int TDEProcess::childOutput ( int  fdno)
protected

Called by slotChildOutput() this function copies data arriving from the child process' stdout to the respective buffer and emits the signal receivedStdout().

Definition at line 831 of file tdeprocess.cpp.

◆ clearArguments()

void TDEProcess::clearArguments ( )

Clear a command line argument list that has been set by using operator<<.

Definition at line 288 of file tdeprocess.cpp.

◆ closeAll()

void TDEProcess::closeAll ( )

Close stdin, stdout, stderr and the pty.

This is the same that calling all close* functions in a row:

See also
closeStdin,
closeStdout,
closeStderr and
closePty

Definition at line 712 of file tdeprocess.cpp.

◆ closePty()

bool TDEProcess::closePty ( )

Deletes the optional utmp entry and closes the pty.

Make sure to shut down any communication links that are using the pty before calling this function.

Returns
false if the pty is not open (any more).

Definition at line 697 of file tdeprocess.cpp.

◆ closeStderr()

bool TDEProcess::closeStderr ( )

Shuts down the Stderr communication link.

If no pty is used, any further attempts by the child to write to its stderr file descriptor will cause it to receive a SIGPIPE.

Returns
false if no Stderr communication link exists (any more).

Definition at line 683 of file tdeprocess.cpp.

◆ closeStdin()

bool TDEProcess::closeStdin ( )

Shuts down the Stdin communication link.

If no pty is used, this causes "EOF" to be indicated on the child's stdin file descriptor.

Returns
false if no Stdin communication link exists (any more).

Definition at line 655 of file tdeprocess.cpp.

◆ closeStdout()

bool TDEProcess::closeStdout ( )

Shuts down the Stdout communication link.

If no pty is used, any further attempts by the child to write to its stdout file descriptor will cause it to receive a SIGPIPE.

Returns
false if no Stdout communication link exists (any more).

Definition at line 669 of file tdeprocess.cpp.

◆ commClose()

void TDEProcess::commClose ( )
protectedvirtual

Cleans up the communication links to the child after it has exited.

This function should act upon the values of pid() and runs. See the tdeprocess.cpp source for details.

  • If pid() returns zero, the communication links should be closed only.
  • if pid() returns non-zero and runs is false, all data immediately available from the communication links should be processed before closing them.
  • if pid() returns non-zero and runs is true, the communication links should be monitored for data until the file handle returned by TDEProcessController::theTDEProcessController->notifierFd() becomes ready for reading - when it triggers, runs should be reset to false, and the function should be immediately left without closing anything.

The previous semantics of this function are forward-compatible, but should be avoided, as they are prone to race conditions and can cause TDEProcess (and thus the whole program) to lock up under certain circumstances. At the end the function closes the communication links in any case. Additionally

  • if runs is true, the communication links are monitored for data until all of them have returned EOF. Note that if any system function is interrupted (errno == EINTR) the polling loop should be aborted.
  • if runs is false, all data immediately available from the communication links is processed.

Definition at line 1032 of file tdeprocess.cpp.

◆ commSetupDoneC()

int TDEProcess::commSetupDoneC ( )
protectedvirtual

Called right after a (successful) fork(), but before an exec() on the child process' side.

It usually duplicates the in[0], out[1] and err[1] file handles to the respective standard I/O handles.

Definition at line 982 of file tdeprocess.cpp.

◆ commSetupDoneP()

int TDEProcess::commSetupDoneP ( )
protectedvirtual

Called right after a (successful) fork() on the parent side.

This function will usually do some communications cleanup, like closing in[0], out[1] and out[1].

Furthermore, it must also create the TQSocketNotifiers innot, outnot and errnot and connect their Qt signals to the respective TDEProcess slots.

For a more detailed explanation, it is best to have a look at the default implementation in tdeprocess.cpp.

Definition at line 937 of file tdeprocess.cpp.

◆ coreDumped()

bool TDEProcess::coreDumped ( ) const

Checks whether a killed process dumped core.

Returns
true if signalled() returns true and the process dumped core. Note that on systems that don't define the WCOREDUMP macro, the return value is always false.
Since
3.2

Definition at line 601 of file tdeprocess.cpp.

◆ detach()

void TDEProcess::detach ( )

Detaches TDEProcess from child process.

All communication is closed. No exit notification is emitted any more for the child process. Deleting the TDEProcess will no longer kill the child process. Note that the current process remains the parent process of the child process.

Definition at line 235 of file tdeprocess.cpp.

◆ exitSignal()

int TDEProcess::exitSignal ( ) const

Returns the signal the process was killed by.

Returns
the signal number that caused the process to exit. Note that this value is not valid if signalled() returns false.
Since
3.2

Definition at line 617 of file tdeprocess.cpp.

◆ exitStatus()

int TDEProcess::exitStatus ( ) const

Returns the exit status of the process.

Returns
the exit status of the process. Note that this value is not valid if normalExit() returns false.

Definition at line 611 of file tdeprocess.cpp.

◆ getPid()

TDE_DEPRECATED pid_t TDEProcess::getPid ( ) const
inline
Deprecated:
Use pid() instead.

Definition at line 323 of file tdeprocess.h.

◆ isRunning()

bool TDEProcess::isRunning ( ) const

Checks whether the process is running.

Returns
true if the process is (still) considered to be running

Definition at line 499 of file tdeprocess.cpp.

◆ kill()

bool TDEProcess::kill ( int  signo = SIGTERM)
virtual

Stop the process (by sending it a signal).

Parameters
signoThe signal to send. The default is SIGTERM.
Returns
true if the signal was delivered successfully.

Definition at line 488 of file tdeprocess.cpp.

◆ normalExit()

bool TDEProcess::normalExit ( ) const

Checks whether the process exited cleanly.

Returns
true if the process has already finished and has exited "voluntarily", ie: it has not been killed by a signal.

Definition at line 589 of file tdeprocess.cpp.

◆ operator<<() [1/4]

TDEProcess & TDEProcess::operator<< ( const char *  arg)

Similar to previous method, takes a char *, supposed to be in locale 8 bit already.

Definition at line 276 of file tdeprocess.cpp.

◆ operator<<() [2/4]

TDEProcess & TDEProcess::operator<< ( const TQCString &  arg)

Similar to previous method, takes a TQCString, supposed to be in locale 8 bit already.

Parameters
argthe argument to add
Returns
a reference to this TDEProcess

Definition at line 271 of file tdeprocess.cpp.

◆ operator<<() [3/4]

TDEProcess & TDEProcess::operator<< ( const TQString &  arg)

Sets the executable and the command line argument list for this process.

For example, doing an "ls -l /usr/local/bin" can be achieved by:

TDEProcess p;
...
p << "ls" << "-l" << "/usr/local/bin"
Parameters
argthe argument to add
Returns
a reference to this TDEProcess

Definition at line 282 of file tdeprocess.cpp.

◆ operator<<() [4/4]

TDEProcess & TDEProcess::operator<< ( const TQStringList &  args)

Sets the executable and the command line argument list for this process, in a single method call, or add a list of arguments.

Parameters
argsthe arguments to add
Returns
a reference to this TDEProcess

Definition at line 263 of file tdeprocess.cpp.

◆ pid()

pid_t TDEProcess::pid ( ) const

Returns the process id of the process.

If it is called after the process has exited, it returns the process id of the last child process that was created by this instance of TDEProcess.

Calling it before any child process has been started by this TDEProcess instance causes pid() to return 0.

Returns
the pid of the process or 0 if no process has been started yet.

Definition at line 506 of file tdeprocess.cpp.

◆ processExited

void TDEProcess::processExited ( TDEProcess *  proc)
signal

Emitted after the process has terminated when the process was run in the NotifyOnExit (==default option to start() ) or the Block mode.

Parameters
proca pointer to the process that has exited

◆ processHasExited()

void TDEProcess::processHasExited ( int  state)
protectedvirtual

Immediately called after a successfully started process in NotifyOnExit mode has exited.

This function normally calls commClose() and emits the processExited() signal.

Parameters
statethe exit code of the process as returned by waitpid()

Definition at line 816 of file tdeprocess.cpp.

◆ pty()

KPty * TDEProcess::pty ( ) const

Obtains the pty object used by this process.

The return value is valid only after setUsePty() was used with a non-zero argument. The pty is open only while the process is running.

Returns
a pointer to the pty object
Since
3.2

Definition at line 798 of file tdeprocess.cpp.

◆ quote()

TQString TDEProcess::quote ( const TQString &  arg)
static

This function can be used to quote an argument string such that the shell processes it properly.

This is e. g. necessary for user-provided file names which may contain spaces or quotes. It also prevents expansion of wild cards and environment variables.

Parameters
argthe argument to quote
Returns
the quoted argument
Since
3.1

Definition at line 804 of file tdeprocess.cpp.

◆ receivedStderr

void TDEProcess::receivedStderr ( TDEProcess *  proc,
char *  buffer,
int  buflen 
)
signal

Emitted, when output from the child process has been received on stderr.

To actually get this signal, the Stderr communication link has to be turned on in start().

You should copy the information contained in buffer to your private data structures before returning from the slot.

Parameters
proca pointer to the process that has received the data
bufferThe data received.
buflenThe number of bytes that are available.

◆ receivedStdout [1/2]

void TDEProcess::receivedStdout ( int  fd,
int &  len 
)
signal

Emitted when output from the child process has been received on stdout.

To actually get this signal, the Stdout communication link has to be turned on in start() and the NoRead flag must have been passed.

You will need to explicitly call resume() after your call to start() to begin processing data from the child process' stdout. This is to ensure that this signal is not emitted when no one is connected to it, otherwise this signal will not be emitted.

The data still has to be read from file descriptor fd.

Parameters
fdthe file descriptor that provides the data
lenthe number of bytes that have been read from fd must be written here

◆ receivedStdout [2/2]

void TDEProcess::receivedStdout ( TDEProcess *  proc,
char *  buffer,
int  buflen 
)
signal

Emitted, when output from the child process has been received on stdout.

To actually get this signal, the Stdout communication link has to be turned on in start().

Parameters
proca pointer to the process that has received the output
bufferThe data received.
buflenThe number of bytes that are available.

You should copy the information contained in buffer to your private data structures before returning from the slot. Example:

TQString myBuf = TQString::fromLatin1(buffer, buflen);

◆ resume()

void TDEProcess::resume ( )

Resume processing of data from stdout of the child process.

Definition at line 649 of file tdeprocess.cpp.

◆ runPrivileged()

bool TDEProcess::runPrivileged ( ) const

Returns whether the started process will drop any setuid/setgid privileges or whether it will keep them.

Returns
true if the process runs privileged

Definition at line 199 of file tdeprocess.cpp.

◆ setBinaryExecutable()

void TDEProcess::setBinaryExecutable ( const char *  filename)
protected

Specify the actual executable that should be started (first argument to execve) Normally the the first argument is the executable but you can override that with this function.

Definition at line 245 of file tdeprocess.cpp.

◆ setEnvironment()

void TDEProcess::setEnvironment ( const TQString &  name,
const TQString &  value 
)

Adds the variable name to the process' environment.

This function must be called before starting the process.

Parameters
namethe name of the environment variable
valuethe new value for the environment variable

Definition at line 166 of file tdeprocess.cpp.

◆ setExecutable()

bool TDEProcess::setExecutable ( const TQString &  proc)
Deprecated:
Use operator<<() instead.

Sets the executable to be started with this TDEProcess object. Returns false if the process is currently running (in that case the executable remains unchanged).

See also
operator<<()

Definition at line 250 of file tdeprocess.cpp.

◆ setPriority()

bool TDEProcess::setPriority ( int  prio)

Sets the scheduling priority of the process.

Parameters
priothe new priority in the range -20 (high) to 19 (low).
Returns
false on error; see setpriority(2) for possible reasons.
Since
3.2

Definition at line 205 of file tdeprocess.cpp.

◆ setRunPrivileged()

void TDEProcess::setRunPrivileged ( bool  keepPrivileges)

Controls whether the started process should drop any setuid/setgid privileges or whether it should keep them.

Note that this function is mostly a dummy, as the KDE libraries currently refuse to run with setuid/setgid privileges.

The default is false: drop privileges

Parameters
keepPrivilegestrue to keep the privileges

Definition at line 193 of file tdeprocess.cpp.

◆ setupCommunication()

int TDEProcess::setupCommunication ( Communication  comm)
protectedvirtual

This function is called from start() right before a fork() takes place.

According to the comm parameter this function has to initialize the in, out and err data members of TDEProcess.

This function should return 1 if setting the needed communication channels was successful.

The default implementation is to create UNIX STREAM sockets for the communication, but you could reimplement this function to establish a TCP/IP communication for network communication, for example.

Definition at line 869 of file tdeprocess.cpp.

◆ setupEnvironment()

void TDEProcess::setupEnvironment ( )
protected

Sets up the environment according to the data passed via setEnvironment()

Definition at line 178 of file tdeprocess.cpp.

◆ setUsePty()

void TDEProcess::setUsePty ( Communication  comm,
bool  addUtmp 
)

Specify whether to create a pty (pseudo-terminal) for running the command.

This function should be called before starting the process.

Parameters
commfor which stdio handles to use a pty. Note that it is not allowed to specify Stdout and Stderr at the same time both here and to start (there is only one pty, so they cannot be distinguished).
addUtmptrue if a utmp entry should be created for the pty
Since
3.2

Definition at line 785 of file tdeprocess.cpp.

◆ setUseShell()

void TDEProcess::setUseShell ( bool  useShell,
const char *  shell = 0 
)

Specify whether to start the command via a shell or directly.

The default is to start the command directly. If useShell is true shell will be used as shell, or if shell is empty, /bin/sh will be used.

When using a shell, the caller should make sure that all filenames etc. are properly quoted when passed as argument.

See also
quote()
Parameters
useShelltrue if the command should be started via a shell
shellthe path to the shell that will execute the process, or 0 to use /bin/sh. Use getenv("SHELL") to use the user's default shell, but note that doing so is usually a bad idea for shell compatibility reasons.
Since
3.1

Definition at line 760 of file tdeprocess.cpp.

◆ setWorkingDirectory()

void TDEProcess::setWorkingDirectory ( const TQString &  dir)

Changes the current working directory (CWD) of the process to be started.

This function must be called before starting the process.

Parameters
dirthe new directory

Definition at line 172 of file tdeprocess.cpp.

◆ signalled()

bool TDEProcess::signalled ( ) const

Checks whether the process was killed by a signal.

Returns
true if the process has already finished and has not exited "voluntarily", ie: it has been killed by a signal.
Since
3.2

Definition at line 595 of file tdeprocess.cpp.

◆ slotChildError

void TDEProcess::slotChildError ( int  fdno)
protectedslot

This slot gets activated when data from the child's stderr arrives.

It usually calls childError().

Parameters
fdnothe file descriptor for the output

Definition at line 733 of file tdeprocess.cpp.

◆ slotChildOutput

void TDEProcess::slotChildOutput ( int  fdno)
protectedslot

This slot gets activated when data from the child's stdout arrives.

It usually calls childOutput().

Parameters
fdnothe file descriptor for the output

Definition at line 726 of file tdeprocess.cpp.

◆ slotSendData

void TDEProcess::slotSendData ( int  dummy)
protectedslot

Called when another bulk of data can be sent to the child's stdin.

If there is no more data to be sent to stdin currently available, this function must disable the TQSocketNotifier innot.

Parameters
dummyignore this argument

Definition at line 740 of file tdeprocess.cpp.

◆ start()

bool TDEProcess::start ( RunMode  runmode = NotifyOnExit,
Communication  comm = NoCommunication 
)
virtual

Starts the process.

For a detailed description of the various run modes and communication semantics, have a look at the general description of the TDEProcess class. Note that if you use setUsePty( Stdout | Stderr, <bool> ), you cannot use Stdout | Stderr here - instead, use Stdout only to receive the mixed output.

The following problems could cause this function to return false:

  • The process is already running.
  • The command line argument list is empty.
  • The the comm parameter is incompatible with the selected pty usage.
  • The starting of the process failed (could not fork).
  • The executable was not found.
Parameters
runmodeThe Run-mode for the process.
commSpecifies which communication links should be established to the child process (stdin/stdout/stderr). By default, no communication takes place and the respective communication signals will never get emitted.
Returns
true on success, false on error (see above for error conditions)

Reimplemented in KShellProcess.

Definition at line 293 of file tdeprocess.cpp.

◆ suspend()

void TDEProcess::suspend ( )

Suspend processing of data from stdout of the child process.

Definition at line 643 of file tdeprocess.cpp.

◆ virtual_hook()

void TDEProcess::virtual_hook ( int  id,
void *  data 
)
protectedvirtual

Definition at line 1102 of file tdeprocess.cpp.

◆ wait()

bool TDEProcess::wait ( int  timeout = -1)

Suspend execution of the current thread until the child process dies or the timeout hits.

This function is not recommended for programs with a GUI.

Parameters
timeouttimeout in seconds. -1 means wait indefinitely.
Returns
true if the process exited, false if the timeout hit.
Since
3.2

Definition at line 523 of file tdeprocess.cpp.

◆ writeStdin()

bool TDEProcess::writeStdin ( const char *  buffer,
int  buflen 
)
Transmit data to the child process' stdin.

This function may return false in the following cases:

@li The process is not currently running.

This implies that you cannot use this function in Block mode.

@li Communication to stdin has not been requested in the start() call.

@li Transmission of data to the child process by a previous call to

writeStdin() is still in progress.

Please note that the data is sent to the client asynchronously, so when this function returns, the data might not have been processed by the child process. That means that you must not free buffer or call writeStdin() again until either a wroteStdin() signal indicates that the data has been sent or a processExited() signal shows that the child process is no longer alive.

If all the data has been sent to the client, the signal wroteStdin() will be emitted.

This function does not work when the process is start()ed in Block mode.

Parameters
bufferthe buffer to write
buflenthe length of the buffer
Returns
false if an error has occurred

Definition at line 623 of file tdeprocess.cpp.

◆ wroteStdin

void TDEProcess::wroteStdin ( TDEProcess *  proc)
signal

Emitted after all the data that has been specified by a prior call to writeStdin() has actually been written to the child process.

Parameters
proca pointer to the process

Friends And Related Function Documentation

◆ TDEProcessController

friend class TDEProcessController
friend

TDEProcessController is a friend of TDEProcess because it has to have access to various data members.

Definition at line 885 of file tdeprocess.h.

Member Data Documentation

◆ arguments

TQValueList<TQCString> TDEProcess::arguments
protected

The list of the process' command line arguments.

The first entry in this list is the executable itself.

Definition at line 696 of file tdeprocess.h.

◆ communication

Communication TDEProcess::communication
protected

Lists the communication links that are activated for the child process.

Should not be modified from derived classes.

Definition at line 852 of file tdeprocess.h.

◆ err

int TDEProcess::err[2]
protected

The socket descriptors for stderr.

Definition at line 833 of file tdeprocess.h.

◆ errnot

TQSocketNotifier* TDEProcess::errnot
protected

The socket notifier for err[0].

Definition at line 846 of file tdeprocess.h.

◆ in

int TDEProcess::in[2]
protected

The socket descriptors for stdin.

Definition at line 829 of file tdeprocess.h.

◆ innot

TQSocketNotifier* TDEProcess::innot
protected

The socket notifier for in[1].

Definition at line 838 of file tdeprocess.h.

◆ input_data

const char* TDEProcess::input_data
protected

The buffer holding the data that has to be sent to the child.

Definition at line 871 of file tdeprocess.h.

◆ input_sent

int TDEProcess::input_sent
protected

The number of bytes already transmitted.

Definition at line 875 of file tdeprocess.h.

◆ input_total

int TDEProcess::input_total
protected

The total length of input_data.

Definition at line 879 of file tdeprocess.h.

◆ keepPrivs

bool TDEProcess::keepPrivs
protected

If false, the child process' effective uid & gid will be reset to the real values.

See also
setRunPrivileged()

Definition at line 734 of file tdeprocess.h.

◆ out

int TDEProcess::out[2]
protected

The socket descriptors for stdout.

Definition at line 825 of file tdeprocess.h.

◆ outnot

TQSocketNotifier* TDEProcess::outnot
protected

The socket notifier for out[0].

Definition at line 842 of file tdeprocess.h.

◆ pid_

pid_t TDEProcess::pid_
protected

The PID of the currently running process.

You should not modify this data member in derived classes. Please use pid() instead of directly accessing this member since it will probably be made private in later versions of TDEProcess.

Definition at line 717 of file tdeprocess.h.

◆ run_mode

RunMode TDEProcess::run_mode
protected

How to run the process (Block, NotifyOnExit, DontCare).

You should not modify this data member directly from derived classes.

Definition at line 701 of file tdeprocess.h.

◆ runs

bool TDEProcess::runs
protected

true if the process is currently running.

You should not modify this data member directly from derived classes. Please use isRunning() for reading the value of this data member since it will probably be made private in later versions of TDEProcess.

Definition at line 708 of file tdeprocess.h.

◆ status

int TDEProcess::status
protected

The process' exit status as returned by waitpid().

You should not modify the value of this data member from derived classes. You should rather use exitStatus() than accessing this data member directly since it will probably be made private in further versions of TDEProcess.

Definition at line 726 of file tdeprocess.h.


The documentation for this class was generated from the following files:
  • tdeprocess.h
  • tdeprocess.cpp

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.