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

tdesu

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
PtyProcess Class Reference

#include <process.h>

Inheritance diagram for PtyProcess:
StubProcess SshProcess SuProcess

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.

Definition at line 36 of file process.h.

Member Enumeration Documentation

◆ checkPidStatus

enum PtyProcess::checkPidStatus

Check process exit status for process pid.

On error (no child, no exit), return -1. If child pid has exited, return its exit status, (which may be zero). If child has not exited, return -2.

Definition at line 162 of file process.h.

Constructor & Destructor Documentation

◆ PtyProcess()

PtyProcess::PtyProcess ( )

Definition at line 124 of file process.cpp.

◆ ~PtyProcess()

PtyProcess::~PtyProcess ( )
virtual

Definition at line 152 of file process.cpp.

Member Function Documentation

◆ checkPid()

bool PtyProcess::checkPid ( pid_t  pid)
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.

◆ checkPidExited()

int PtyProcess::checkPidExited ( pid_t  pid)
static

Definition at line 96 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.

◆ environment()

const QCStringList & PtyProcess::environment ( ) const
protected

Definition at line 164 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
commandThe command to execute.
argsThe arguments to the command.

Definition at line 324 of file process.cpp.

◆ fd()

int PtyProcess::fd ( )
inline

Returns the filedescriptor of the process.

Definition at line 121 of file process.h.

◆ pid()

int PtyProcess::pid ( )
inline

Returns the pid of the process.

Definition at line 126 of file process.h.

◆ readAll()

TQCString PtyProcess::readAll ( bool  block = true)

Read all available output from the program's standard out.

Parameters
blockIf 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
blockBlock 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()

void PtyProcess::setErase ( bool  erase)
inline

Overwrites the password as soon as it is used.

Relevant only to some subclasses.

Definition at line 111 of file process.h.

◆ setExitString()

void PtyProcess::setExitString ( const TQCString &  exit)
inline

Sets the exit string.

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

Definition at line 83 of file process.h.

◆ setTerminal()

void PtyProcess::setTerminal ( bool  terminal)
inline

Enables/disables terminal output.

Relevant only to some subclasses.

Definition at line 105 of file process.h.

◆ unreadLine()

void PtyProcess::unreadLine ( const TQCString &  line,
bool  addNewline = true 
)

Puts back a line of input.

Parameters
lineThe line to put back.
addNewlineAdds a '
' to the line.

Definition at line 311 of file process.cpp.

◆ virtual_hook()

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

Definition at line 631 of file process.cpp.

◆ waitForChild()

int PtyProcess::waitForChild ( )

Waits for the child to exit.

See also setExitString.

Definition at line 487 of file process.cpp.

◆ waitMS()

int PtyProcess::waitMS ( int  fd,
int  ms 
)
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
lineThe text to write.
addNewlineAdds a '
' to the line.

Definition at line 302 of file process.cpp.

Member Data Documentation

◆ m_bErase

bool PtyProcess::m_bErase
protected

Definition at line 169 of file process.h.

◆ m_bTerminal

bool PtyProcess::m_bTerminal
protected

Definition at line 169 of file process.h.

◆ m_Command

TQCString PtyProcess::m_Command
protected

Definition at line 171 of file process.h.

◆ m_Exit

TQCString PtyProcess::m_Exit
protected

Definition at line 171 of file process.h.

◆ m_Fd

int PtyProcess::m_Fd
protected

Definition at line 170 of file process.h.

◆ m_Pid

int PtyProcess::m_Pid
protected

Definition at line 170 of file process.h.


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

tdesu

Skip menu "tdesu"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

tdesu

Skip menu "tdesu"
  • 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 tdesu by doxygen 1.9.4
This website is maintained by Timothy Pearson.