PtyProcess Class Reference

#include <process.h>

Inheritance diagram for PtyProcess:

StubProcess SshProcess SuProcess List of all members.

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.

Definition at line 36 of file process.h.


Public Types

 Error = -1
 NotExited = -2
 Killed = -3
enum  checkPidStatus { Error = -1, NotExited = -2, Killed = -3 }

Public Member Functions

 PtyProcess ()
virtual ~PtyProcess ()
int exec (const QCString &command, const QCStringList &args)
QCString readLine (bool block=true)
void writeLine (const QCString &line, bool addNewline=true)
void unreadLine (const QCString &line, bool addNewline=true)
void setExitString (const QCString &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 bool checkPid (pid_t pid)
static int checkPidExited (pid_t pid)

Public Attributes

public __pad0__: static int waitMS(int fd
public int ms

Protected Member Functions

const QCStringListenvironment () const
virtual void virtual_hook (int id, void *data)

Protected Attributes

bool m_bErase
bool m_bTerminal
int m_Pid
int m_Fd
QCString m_Command
QCString m_Exit

Member Function Documentation

int PtyProcess::enableLocalEcho ( bool  enable = true  ) 

Enables/disables local echo on the pseudo tty.

Definition at line 387 of file process.cpp.

int PtyProcess::exec ( const QCString 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 261 of file process.cpp.

int PtyProcess::fd (  )  [inline]

Returns the filedescriptor of the process.

Definition at line 115 of file process.h.

int PtyProcess::pid (  )  [inline]

Returns the pid of the process.

Definition at line 120 of file process.h.

QCString 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 166 of file process.cpp.

void PtyProcess::setEnvironment ( const QCStringList env  ) 

Set additinal environment variables.

Definition at line 150 of file process.cpp.

void PtyProcess::setErase ( bool  erase  )  [inline]

Overwrites the password as soon as it is used.

Relevant only to some subclasses.

Definition at line 105 of file process.h.

void PtyProcess::setExitString ( const QCString exit  )  [inline]

Sets the exit string.

If a line of program output matches this, waitForChild() will terminate the program and return.

Definition at line 77 of file process.h.

void PtyProcess::setTerminal ( bool  terminal  )  [inline]

Enables/disables terminal output.

Relevant only to some subclasses.

Definition at line 99 of file process.h.

void PtyProcess::unreadLine ( const QCString 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 248 of file process.cpp.

int PtyProcess::waitForChild (  ) 

Waits for the child to exit.

See also setExitString.

Definition at line 423 of file process.cpp.

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 349 of file process.cpp.

void PtyProcess::writeLine ( const QCString 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 239 of file process.cpp.


The documentation for this class was generated from the following files:
KDE Home | KDE Accessibility Home | Description of Access Keys