#include <process.h>
Public Types | |
enum | checkPidStatus { Error =-1 , NotExited =-2 , Killed =-3 } |
Public Member Functions | |
int | exec (const TQCString &command, const QCStringList &args) |
TQCString | readLine (bool block=true) |
TQCString | readAll (bool block=true) |
void | writeLine (const TQCString &line, bool addNewline=true) |
void | unreadLine (const TQCString &line, bool addNewline=true) |
void | setExitString (const TQCString &exit) |
int | waitForChild () |
int | WaitSlave () |
int | enableLocalEcho (bool enable=true) |
void | setTerminal (bool terminal) |
void | setErase (bool erase) |
void | setEnvironment (const QCStringList &env) |
int | fd () |
int | pid () |
Static Public Member Functions | |
static int | waitMS (int fd, int ms) |
static bool | checkPid (pid_t pid) |
static int | checkPidExited (pid_t pid) |
Protected Member Functions | |
const QCStringList & | environment () const |
virtual void | virtual_hook (int id, void *data) |
Protected Attributes | |
bool | m_bErase |
bool | m_bTerminal |
int | m_Pid |
int | m_Fd |
TQCString | m_Command |
TQCString | m_Exit |
Detailed Description
Synchronous communication with tty programs.
PtyProcess provides synchronous communication with tty based programs. The communications channel used is a pseudo tty (as opposed to a pipe) This means that programs which require a terminal will work.
Member Enumeration Documentation
◆ checkPidStatus
Member Function Documentation
◆ checkPid()
|
static |
Basic check for the existence of pid
.
Returns true iff pid
is an extant process, (one you could kill - see man kill(2) for signal 0).
Definition at line 75 of file process.cpp.
◆ enableLocalEcho()
int PtyProcess::enableLocalEcho | ( | bool | enable = true | ) |
Enables/disables local echo on the pseudo tty.
Definition at line 451 of file process.cpp.
◆ exec()
int PtyProcess::exec | ( | const TQCString & | command, |
const QCStringList & | args | ||
) |
Forks off and execute a command.
The command's standard in and output are connected to the pseudo tty. They are accessible with readLine and writeLine.
- Parameters
-
command The command to execute. args The arguments to the command.
Definition at line 324 of file process.cpp.
◆ fd()
|
inline |
◆ pid()
|
inline |
◆ readAll()
TQCString PtyProcess::readAll | ( | bool | block = true | ) |
Read all available output from the program's standard out.
- Parameters
-
block If no output is in the buffer, should the function block
- Returns
- The output.
Definition at line 247 of file process.cpp.
◆ readLine()
TQCString PtyProcess::readLine | ( | bool | block = true | ) |
Reads a line from the program's standard out.
Depending on the block parameter, this call blocks until a single, full line is read.
- Parameters
-
block Block until a full line is read?
- Returns
- The output string.
Definition at line 175 of file process.cpp.
◆ setEnvironment()
void PtyProcess::setEnvironment | ( | const QCStringList & | env | ) |
Set additinal environment variables.
Definition at line 159 of file process.cpp.
◆ setErase()
|
inline |
◆ setExitString()
|
inline |
Sets the exit string.
If a line of program output matches this, waitForChild() will terminate the program and return.
◆ setTerminal()
|
inline |
◆ unreadLine()
void PtyProcess::unreadLine | ( | const TQCString & | line, |
bool | addNewline = true |
||
) |
Puts back a line of input.
- Parameters
-
line The line to put back. addNewline Adds a '
' to the line.
Definition at line 311 of file process.cpp.
◆ waitForChild()
int PtyProcess::waitForChild | ( | ) |
◆ waitMS()
|
static |
Wait ms
miliseconds (ie.
1/10th of a second is 100ms), using fd
as a filedescriptor to wait on. Returns select(2)'s result, which is -1 on error, 0 on timeout, or positive if there is data on one of the selected fd's.
ms
must be in the range 0..999 (ie. the maximum wait duration is 999ms, almost one second).
Definition at line 59 of file process.cpp.
◆ WaitSlave()
int PtyProcess::WaitSlave | ( | ) |
Waits until the pty has cleared the ECHO flag.
This is useful when programs write a password prompt before they disable ECHO. Disabling it might flush any input that was written.
Definition at line 413 of file process.cpp.
◆ writeLine()
void PtyProcess::writeLine | ( | const TQCString & | line, |
bool | addNewline = true |
||
) |
Writes a line of text to the program's standard in.
- Parameters
-
line The text to write. addNewline Adds a '
' to the line.
Definition at line 302 of file process.cpp.
The documentation for this class was generated from the following files: