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

KPty

KPty Class Reference

Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY, utmp registration and setting various terminal attributes. More...

#include <kpty.h>

Inheritance diagram for KPty:
KPtyDevice

List of all members.

Public Member Functions

void close ()
void closeSlave ()
 KPty ()
void login (const char *user=0, const char *remotehost=0)
void logout ()
int masterFd () const
bool open (int fd)
bool open ()
bool openSlave ()
void setCTty ()
bool setEcho (bool echo)
bool setWinSize (int lines, int columns)
int slaveFd () const
bool tcGetAttr (struct::termios *ttmode) const
bool tcSetAttr (struct::termios *ttmode)
const char * ttyName () const
 ~KPty ()

Protected Member Functions

 KPty (KPtyPrivate *d)

Protected Attributes

KPtyPrivate *const d_ptr

Detailed Description

Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY, utmp registration and setting various terminal attributes.

Definition at line 33 of file kpty.h.


Constructor & Destructor Documentation

KPty::KPty (  ) 

Constructor.

Definition at line 167 of file kpty.cpp.

KPty::~KPty (  ) 

Destructor:.

If the pty is still open, it will be closed. Note, however, that an utmp registration is not undone.

Definition at line 178 of file kpty.cpp.

KPty::KPty ( KPtyPrivate *  d  )  [protected]

For internal use only.

Definition at line 172 of file kpty.cpp.


Member Function Documentation

void KPty::close (  ) 

Close the pty master/slave pair.

Reimplemented in KPtyDevice.

Definition at line 427 of file kpty.cpp.

void KPty::closeSlave (  ) 

Close the pty slave descriptor.

When creating the pty, KPty also opens the slave and keeps it open. Consequently the master will never receive an EOF notification. Usually this is the desired behavior, as a closed pty slave can be reopened any time - unlike a pipe or socket. However, in some cases pipe-alike behavior might be desired.

After this function was called, slaveFd() and setCTty() cannot be used.

Definition at line 398 of file kpty.cpp.

void KPty::login ( const char *  user = 0,
const char *  remotehost = 0 
)

Creates an utmp entry for the tty.

This function must be called after calling setCTty and making this pty the stdin.

Parameters:
user the user to be logged on
remotehost the host from which the login is coming. This is not the local host. For remote logins it should be the hostname of the client. For local logins from inside an X session it should be the name of the X display. Otherwise it should be empty.

Definition at line 482 of file kpty.cpp.

void KPty::logout (  ) 

Removes the utmp entry for this tty.

Definition at line 560 of file kpty.cpp.

int KPty::masterFd (  )  const
Returns:
the file descriptor of the master pty

This function should be called only while the pty is open.

Definition at line 674 of file kpty.cpp.

bool KPty::open ( int  fd  ) 

Open using an existing pty master.

Parameters:
fd an open pty master file descriptor. The ownership of the fd remains with the caller; it will not be automatically closed at any point.
Returns:
true if a pty pair was successfully opened

Definition at line 357 of file kpty.cpp.

bool KPty::open (  ) 

Create a pty master/slave pair.

Returns:
true if a pty pair was successfully opened

Definition at line 184 of file kpty.cpp.

bool KPty::openSlave (  ) 

Open the pty slave descriptor.

This undoes the effect of closeSlave().

Returns:
true if the pty slave was successfully opened

Definition at line 408 of file kpty.cpp.

void KPty::setCTty (  ) 

Creates a new session and process group and makes this pty the controlling tty.

Definition at line 455 of file kpty.cpp.

bool KPty::setEcho ( bool  echo  ) 

Set whether the pty should echo input.

Echo is on by default. If the output of automatically fed (non-interactive) PTY clients needs to be parsed, disabling echo often makes it much simpler.

This function can be used only while the PTY is open.

Parameters:
echo true if input should be echoed.
Returns:
true on success, false otherwise

Definition at line 655 of file kpty.cpp.

bool KPty::setWinSize ( int  lines,
int  columns 
)

Change the logical (screen) size of the pty.

The default is 24 lines by 80 columns.

This function can be used only while the PTY is open.

Parameters:
lines the number of rows
columns the number of columns
Returns:
true on success, false otherwise

Definition at line 644 of file kpty.cpp.

int KPty::slaveFd (  )  const
Returns:
the file descriptor of the slave pty

This function should be called only while the pty slave is open.

Definition at line 681 of file kpty.cpp.

bool KPty::tcGetAttr ( struct::termios *  ttmode  )  const

Wrapper around tcgetattr(3).

This function can be used only while the PTY is open. You will need an include <termios.h> to do anything useful with it.

Parameters:
ttmode a pointer to a termios structure. Note: when declaring ttmode, struct termios must be used - without the '::' some version of HP-UX thinks, this declares the struct in your class, in your method.
Returns:
true on success, false otherwise

Definition at line 630 of file kpty.cpp.

bool KPty::tcSetAttr ( struct::termios *  ttmode  ) 

Wrapper around tcsetattr(3) with mode TCSANOW.

This function can be used only while the PTY is open.

Parameters:
ttmode a pointer to a termios structure.
Returns:
true on success, false otherwise. Note that success means that at least one attribute could be set.

Definition at line 637 of file kpty.cpp.

const char * KPty::ttyName (  )  const
Returns:
the name of the slave pty device.

This function should be called only while the pty is open.

Definition at line 667 of file kpty.cpp.


Member Data Documentation

KPtyPrivate* const KPty::d_ptr [protected]

For internal use only.

Definition at line 201 of file kpty.h.


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

KPty

Skip menu "KPty"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • 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
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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