• Skip to content
  • Skip to link menu
KDE 4.1 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDEsu

KDESu::PtyProcess

KDESu::PtyProcess Class Reference

#include <kdesu/process.h>

Inheritance diagram for KDESu::PtyProcess:

Inheritance graph
[legend]

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 37 of file process.h.


Public Types

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

Public Member Functions

int enableLocalEcho (bool enable=true)
int exec (const QByteArray &command, const QList< QByteArray > &args)
int fd () const
int pid () const
 PtyProcess ()
QByteArray readAll (bool block=true)
QByteArray readLine (bool block=true)
void setEnvironment (const QList< QByteArray > &env)
void setErase (bool erase)
void setExitString (const QByteArray &exit)
void setTerminal (bool terminal)
void unreadLine (const QByteArray &line, bool addNewline=true)
int waitForChild ()
int WaitSlave ()
void writeLine (const QByteArray &line, bool addNewline=true)
virtual ~PtyProcess ()

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

QList< QByteArray > environment () const
virtual void virtual_hook (int id, void *data)

Protected Attributes

bool m_bErase
bool m_bTerminal
QByteArray m_Command
QByteArray m_Exit
int m_Pid

Member Enumeration Documentation

enum KDESu::PtyProcess::checkPidStatus

Error return values for checkPidExited().

Enumerator:
Error  No child.
NotExited  Child hasn't exited.
Killed  Child terminated by signal.

Definition at line 163 of file process.h.


Constructor & Destructor Documentation

KDESu::PtyProcess::PtyProcess (  ) 

Definition at line 136 of file process.cpp.

KDESu::PtyProcess::~PtyProcess (  )  [virtual]

Definition at line 158 of file process.cpp.


Member Function Documentation

bool KDESu::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 80 of file process.cpp.

int KDESu::PtyProcess::checkPidExited ( pid_t  pid  )  [static]

Check process exit status for process pid.

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

Definition at line 101 of file process.cpp.

int KDESu::PtyProcess::enableLocalEcho ( bool  enable = true  ) 

Enables/disables local echo on the pseudo tty.

Definition at line 406 of file process.cpp.

QList< QByteArray > KDESu::PtyProcess::environment (  )  const [protected]

Returns the additional environment variables set by setEnvironment().

Definition at line 180 of file process.cpp.

int KDESu::PtyProcess::exec ( const QByteArray &  command,
const QList< QByteArray > &  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.
Returns:
0 on success, -1 on error. errno might give more information then.

Definition at line 292 of file process.cpp.

int KDESu::PtyProcess::fd (  )  const

Returns the filedescriptor of the process.

Definition at line 169 of file process.cpp.

int KDESu::PtyProcess::pid (  )  const

Returns the pid of the process.

Definition at line 174 of file process.cpp.

QByteArray KDESu::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 (else it will return an empty QByteArray)?
Returns:
The output.

Definition at line 186 of file process.cpp.

QByteArray KDESu::PtyProcess::readLine ( bool  block = true  ) 

Reads a line from the program's standard out.

Depending on the block parameter, this call blocks until something was read. Note that in some situations this function will return less than a full line of output, but never more. Newline characters are stripped.

Parameters:
block Block until a full line is read?
Returns:
The output string.

Definition at line 240 of file process.cpp.

void KDESu::PtyProcess::setEnvironment ( const QList< QByteArray > &  env  ) 

Set additinal environment variables.

Set additional environment variables.

Definition at line 164 of file process.cpp.

void KDESu::PtyProcess::setErase ( bool  erase  ) 

Overwrites the password as soon as it is used.

Relevant only to some subclasses.

Definition at line 417 of file process.cpp.

void KDESu::PtyProcess::setExitString ( const QByteArray &  exit  ) 

Sets the exit string.

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

Definition at line 283 of file process.cpp.

void KDESu::PtyProcess::setTerminal ( bool  terminal  ) 

Enables/disables terminal output.

Relevant only to some subclasses.

Definition at line 412 of file process.cpp.

void KDESu::PtyProcess::unreadLine ( const QByteArray &  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 274 of file process.cpp.

void KDESu::PtyProcess::virtual_hook ( int  id,
void *  data 
) [protected, virtual]

Standard hack to add virtual methods in a BC way.

Unused.

Reimplemented in KDESu::SshProcess, KDESu::StubProcess, and KDESu::SuProcess.

Definition at line 549 of file process.cpp.

int KDESu::PtyProcess::waitForChild (  ) 

Waits for the child to exit.

See also setExitString.

Definition at line 430 of file process.cpp.

int KDESu::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 378 of file process.cpp.

void KDESu::PtyProcess::writeLine ( const QByteArray &  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 265 of file process.cpp.


Member Data Documentation

public KDESu::PtyProcess::__pad0__

Definition at line 151 of file process.h.

bool KDESu::PtyProcess::m_bErase [protected]

See also:
setErase()

Definition at line 181 of file process.h.

bool KDESu::PtyProcess::m_bTerminal [protected]

Indicates running in a terminal, causes additional newlines to be printed after output.

Set to false in constructor.

See also:
setTerminal()

Definition at line 181 of file process.h.

QByteArray KDESu::PtyProcess::m_Command [protected]

Unused.

Reimplemented in KDESu::StubProcess.

Definition at line 186 of file process.h.

QByteArray KDESu::PtyProcess::m_Exit [protected]

String to scan for in output that indicates child has exited.

Definition at line 186 of file process.h.

int KDESu::PtyProcess::m_Pid [protected]

PID of child process.

Definition at line 185 of file process.h.

public int KDESu::PtyProcess::ms

Definition at line 151 of file process.h.


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

KDEsu

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

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • KIO
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • Kross
  • KUtils
  • Nepomuk
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal