org.kde.koala
public class KProcess extends QObject
KProcess proc = new KProcess; proc << "my_executable"; proc << "These" << "are" << "the" << "command" << "line" << "args"; QApplication.connect(proc, SIGNAL("processExited(KProcess )"), pointer_to_my_object, SLOT("my_objects_slot(KProcess )")); proc.start();This will start "my_executable" with the commandline arguments "These"... When the child process exits, the slot will be invoked.
See Also: KProcIO
UNKNOWN: Child process invocation, monitoring and control.
Field Summary | |
---|---|
static int | All |
static int | AllOutput |
static int | Block |
static int | DontCare
Run-modes for a child process. |
static int | NoCommunication
Modes in which the communication channel can be opened.
|
static int | NoRead |
static int | NotifyOnExit |
static int | OwnGroup |
static int | PrioHigh |
static int | PrioHigher |
static int | PrioHighest |
static int | PrioLow |
static int | PrioLower |
static int | PrioLowest
More or less intuitive constants for use with setPriority(). |
static int | PrioNormal |
static int | Stderr |
static int | Stdin |
static int | Stdout |
Constructor Summary | |
---|---|
protected | KProcess(Class dummy) |
KProcess(QObject parent, String name)
Constructor | |
KProcess(QObject parent) | |
KProcess()
Constructor |
Method Summary | |
---|---|
protected int | childError(int fdno)
Called by slotChildError() this function copies data arriving from
the child process' stderr to the respective buffer and emits the signal
receivedStderr(). |
protected int | childOutput(int fdno)
Called by slotChildOutput() this function copies data arriving from
the child process' stdout to the respective buffer and emits the signal
receivedStdout(). |
String | className() |
void | clearArguments()
Clear a command line argument list that has been set by using
operator<<. |
void | closeAll() |
boolean | closePty()
Deletes the optional utmp entry and closes the pty.
|
boolean | closeStderr()
Shuts down the Stderr communication link. |
boolean | closeStdin()
Shuts down the Stdin communication link. |
boolean | closeStdout()
Shuts down the Stdout communication link. |
protected void | commClose()
Cleans up the communication links to the child after it has exited.
|
protected int | commSetupDoneC()
Called right after a (successful) fork(), but before an exec() on the child
process' side. |
protected int | commSetupDoneP()
Called right after a (successful) fork() on the parent side. |
boolean | coreDumped()
Checks whether a killed process dumped core. |
void | detach()
Detaches KProcess from child process. |
void | dispose() Delete the wrapped C++ instance ahead of finalize() |
int | exitSignal()
Returns the signal the process was killed by. |
int | exitStatus()
Returns the exit status of the process. |
protected void | finalize() Deletes the wrapped C++ instance |
boolean | isDisposed() Has the wrapped C++ instance been deleted? |
boolean | isRunning()
Checks whether the process is running. |
boolean | kill(int signo)
Stop the process (by sending it a signal). |
boolean | kill() |
QMetaObject | metaObject() |
boolean | normalExit()
Checks whether the process exited cleanly. |
KProcess | op_write(String arg)
Sets the executable and the command line argument list for this process.
|
KProcess | op_write(String[] args)
Sets the executable and the command line argument list for this process,
in a single method call, or add a list of arguments. |
int | pid() Returns the process id of the process.
|
protected void | processHasExited(int state)
Immediately called after a successfully started process in NotifyOnExit
mode has exited. |
static String | quote(String arg)
This function can be used to quote an argument string such that
the shell processes it properly. |
void | resume()
Resume processing of data from stdout of the child process. |
boolean | runPrivileged()
Returns whether the started process will drop any
setuid/setgid privileges or whether it will keep them. |
protected void | setBinaryExecutable(String filename)
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. |
void | setEnvironment(String name, String value)
Adds the variable name to the process' environment.
|
boolean | setPriority(int prio)
Sets the scheduling priority of the process. |
void | setRunPrivileged(boolean keepPrivileges)
Controls whether the started process should drop any
setuid/setgid privileges or whether it should keep them.
|
protected int | setupCommunication(int comm)
This function is called from start() right before a fork() takes
place. |
protected void | setupEnvironment()
Sets up the environment according to the data passed via
setEnvironment() |
void | setUseShell(boolean useShell, String shell)
Specify whether to start the command via a shell or directly.
|
void | setUseShell(boolean useShell) |
void | setWorkingDirectory(String dir)
Changes the current working directory (CWD) of the process
to be started.
|
boolean | signalled()
Checks whether the process was killed by a signal. |
protected void | slotChildError(int fdno)
This slot gets activated when data from the child's stderr arrives.
|
protected void | slotChildOutput(int fdno)
This slot gets activated when data from the child's stdout arrives.
|
protected void | slotSendData(int dummy)
Called when another bulk of data can be sent to the child's
stdin. |
boolean | start(int runmode, int comm)
Starts the process.
|
boolean | start(int runmode) |
boolean | start() |
void | suspend()
Suspend processing of data from stdout of the child process. |
boolean | waitThread(int timeout)
Suspend execution of the current thread until the child process dies
or the timeout hits. |
boolean | waitThread() |
boolean | writeStdin(String buffer, int buflen)
Transmit data to the child process' stdin.
|
UNKNOWN: Run-modes for a child process.
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.UNKNOWN: Modes in which the communication channel can be opened.
UNKNOWN: More or less intuitive constants for use with setPriority().
UNKNOWN: Constructor
UNKNOWN: Constructor
UNKNOWN: Called by slotChildError() this function copies data arriving from the child process' stderr to the respective buffer and emits the signal receivedStderr().
UNKNOWN: Called by slotChildOutput() this function copies data arriving from the child process' stdout to the respective buffer and emits the signal receivedStdout().
UNKNOWN: Clear a command line argument list that has been set by using operator<<.
See Also: KProcess @see
KProcess @see
KProcess @see
KProcess
UNKNOWN: Close stdin, stdout, stderr and the pty This is the same that calling all close functions in a row: @brief Close stdin, stdout, stderr and the pty
Returns: false if the pty is not open (any more).
UNKNOWN: Deletes the optional utmp entry and closes the pty.
Returns: false if no Stderr communication link exists (any more).
UNKNOWN: Shuts down the Stderr communication link.
Returns: false if no Stdin communication link exists (any more).
UNKNOWN: Shuts down the Stdin communication link.
Returns: false if no Stdout communication link exists (any more).
UNKNOWN: Shuts down the Stdout communication link.
UNKNOWN: Called right after a (successful) fork(), but before an exec() on the child process' side.
UNKNOWN: Called right after a (successful) fork() on the parent side.
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.
UNKNOWN: Checks whether a killed process dumped core.
UNKNOWN: Detaches KProcess from child process.
Returns: the signal number that caused the process to exit. Note that this value is not valid if signalled() returns false.
UNKNOWN: Returns the signal the process was killed by.
Returns: the exit status of the process. Note that this value is not valid if normalExit() returns false.
UNKNOWN: Returns the exit status of the process.
Returns: true if the process is (still) considered to be running
UNKNOWN: Checks whether the process is running.
Parameters: signo The signal to send. The default is SIGTERM.
Returns: true if the signal was delivered successfully.
UNKNOWN: Stop the process (by sending it a signal).
Returns: true if the process has already finished and has exited "voluntarily", ie: it has not been killed by a signal.
UNKNOWN: Checks whether the process exited cleanly.
KProcess p; ... p << "ls" << "-l" << "/usr/local/bin"
Parameters: arg the argument to add
Returns: a reference to this KProcess
UNKNOWN: Sets the executable and the command line argument list for this process.
Parameters: args the arguments to add
Returns: a reference to this KProcess
UNKNOWN: Sets the executable and the command line argument list for this process, in a single method call, or add a list of arguments.
Returns: the pid of the process or 0 if no process has been started yet.
UNKNOWN: Returns the process id of the process.
Parameters: state the exit code of the process as returned by waitpid()
UNKNOWN: Immediately called after a successfully started process in NotifyOnExit mode has exited.
Parameters: arg the argument to quote
Returns: the quoted argument
UNKNOWN: This function can be used to quote an argument string such that the shell processes it properly.
UNKNOWN: Resume processing of data from stdout of the child process.
Returns: true if the process runs privileged
UNKNOWN: Returns whether the started process will drop any setuid/setgid privileges or whether it will keep them.
UNKNOWN: 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.
name
to the process' environment.
This function must be called before starting the process.Parameters: name the name of the environment variable value the new value for the environment variable
UNKNOWN: Adds the variable name
to the process' environment.
Parameters: prio the new priority in the range -20 (high) to 19 (low).
Returns: false on error; see setpriority(2) for possible reasons.
UNKNOWN: Sets the scheduling priority of the process.
Parameters: keepPrivileges true to keep the privileges
UNKNOWN: Controls whether the started process should drop any setuid/setgid privileges or whether it should keep them.
comm
parameter this function has to initialize
the in, out and err data members of KProcess.
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.UNKNOWN: This function is called from start() right before a fork() takes place.
UNKNOWN: Sets up the environment according to the data passed via setEnvironment()
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.Parameters: useShell true if the command should be started via a shell shell the 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.
See Also: KProcess
UNKNOWN: Specify whether to start the command via a shell or directly.
Parameters: dir the new directory
UNKNOWN: Changes the current working directory (CWD) of the process to be started.
Returns: true if the process has already finished and has not exited "voluntarily", ie: it has been killed by a signal.
UNKNOWN: Checks whether the process was killed by a signal.
Parameters: fdno the file descriptor for the output
UNKNOWN: This slot gets activated when data from the child's stderr arrives.
Parameters: fdno the file descriptor for the output
UNKNOWN: This slot gets activated when data from the child's stdout arrives.
Parameters: dummy ignore this argument
UNKNOWN: Called when another bulk of data can be sent to the child's stdin.
comm
parameter is incompatible with the selected pty usage.
Parameters: runmode The Run-mode for the process. comm Specifies 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)
UNKNOWN: Starts the process.
UNKNOWN: Suspend processing of data from stdout of the child process.
Parameters: timeout timeout in seconds. -1 means wait indefinitely.
Returns: true if the process exited, false if the timeout hit.
UNKNOWN: Suspend execution of the current thread until the child process dies or the timeout hits.
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.Parameters: buffer the buffer to write buflen the length of the buffer
Returns: false if an error has occurred
UNKNOWN: Transmit data to the child process' stdin.