#include <shellprocess.h>
Inherits KShellProcess.
Public Types | |
enum | Status { INACTIVE , RUNNING , SUCCESS , UNAUTHORISED , DIED , NOT_FOUND , START_FAIL } |
Signals | |
void | shellExited (ShellProcess *) |
Public Member Functions | |
ShellProcess (const TQString &command) | |
bool | start (Communication comm=NoCommunication) |
Status | status () const |
bool | normalExit () const |
const TQString & | command () const |
TQString | errorMessage () const |
void | writeStdin (const char *buffer, int bufflen) |
void | stdinExit () |
Static Public Member Functions | |
static bool | authorised () |
static const TQCString & | shellName () |
static const TQCString & | shellPath () |
Detailed Description
Enhanced KShellProcess.
The ShellProcess class runs a shell command and interprets the shell exit status as far as possible. It blocks execution if shell access is prohibited. It buffers data written to the process's stdin.
Before executing any command, ShellProcess checks whether shell commands are allowed at all. If not (e.g. if the user is running in kiosk mode), it blocks execution.
Derived from KShellProcess, this class additionally tries to interpret the shell exit status. Different shells use different exit codes. Currently, if bash or ksh report that the command could not be found or could not be executed, the NOT_FOUND status is returned.
Writes to the process's stdin are buffered, so that unlike with KShellProcess, there is no need to wait for the write to complete before writing again.
Definition at line 50 of file shellprocess.h.
Member Enumeration Documentation
◆ Status
enum ShellProcess::Status |
Current status of the shell process.
- INACTIVE - start() has not yet been called to run the command.
- RUNNING - the command is currently running.
- SUCCESS - the command appears to have exited successfully.
- UNAUTHORISED - shell commands are not authorised for this user.
- DIED - the command didn't exit cleanly, i.e. was killed or died.
- NOT_FOUND - the command was either not found or not executable.
- START_FAIL - the command couldn't be started for other reasons.
Definition at line 64 of file shellprocess.h.
Constructor & Destructor Documentation
◆ ShellProcess()
|
explicit |
Constructor.
- Parameters
-
command The command line to be run when start() is called.
Definition at line 40 of file shellprocess.cpp.
Member Function Documentation
◆ authorised()
|
static |
Returns whether the user is authorised to run shell commands.
Shell commands may be prohibited in kiosk mode, for example.
Definition at line 200 of file shellprocess.cpp.
◆ command()
|
inline |
Returns the command configured to be run.
Definition at line 89 of file shellprocess.h.
◆ errorMessage()
TQString ShellProcess::errorMessage | ( | ) | const |
Returns the error message corresponding to the command exit status.
- Returns
- Error message if an error occurred. Null string if the command has not yet exited, or if the command ran successfully.
Definition at line 141 of file shellprocess.cpp.
◆ normalExit()
|
inline |
Returns whether the command was run successfully.
- Returns
- True if the command has been run and appears to have exited successfully.
Definition at line 87 of file shellprocess.h.
◆ shellExited
|
signal |
Signal emitted when the shell process execution completes.
It is not emitted if start() did not attempt to start the command execution, e.g. in kiosk mode.
◆ shellName()
|
inlinestatic |
Determines which shell to use.
- Returns
- file name of shell, excluding path.
Definition at line 106 of file shellprocess.h.
◆ shellPath()
|
static |
Determines which shell to use.
- Returns
- path name of shell.
Definition at line 165 of file shellprocess.cpp.
◆ start()
bool ShellProcess::start | ( | Communication | comm = NoCommunication | ) |
Executes the configured command.
- Parameters
-
comm Which communication links should be established to the child process (stdin/stdout/stderr).
Definition at line 51 of file shellprocess.cpp.
◆ status()
|
inline |
Returns the current status of the shell process.
Definition at line 83 of file shellprocess.h.
◆ stdinExit()
void ShellProcess::stdinExit | ( | ) |
Tell the process to exit once any outstanding STDIN strings have been written.
Definition at line 129 of file shellprocess.cpp.
◆ writeStdin()
void ShellProcess::writeStdin | ( | const char * | buffer, |
int | bufflen | ||
) |
Writes a string to the process's STDIN.
Definition at line 102 of file shellprocess.cpp.
The documentation for this class was generated from the following files: