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

KPty

Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
KPty Class Reference

#include <kpty.h>

Inheritance diagram for KPty:
Inheritance graph
[legend]

Public Member Functions

 KPty ()
 
 ~KPty ()
 
void close ()
 
void closeSlave ()
 
void login (const char *user=0, const char *remotehost=0)
 
void logout ()
 
int masterFd () const
 
bool open ()
 
bool open (int fd)
 
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
 

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 177 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 188 of file kpty.cpp.

KPty::KPty ( KPtyPrivate *  d)
protected

Definition at line 182 of file kpty.cpp.

Member Function Documentation

void KPty::close ( )

Close the pty master/slave pair.

Definition at line 446 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 417 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
userthe user to be logged on
remotehostthe 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 501 of file kpty.cpp.

void KPty::logout ( )

Removes the utmp entry for this tty.

Definition at line 579 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 696 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 194 of file kpty.cpp.

bool KPty::open ( int  fd)

Open using an existing pty master.

Parameters
fdan 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 376 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 427 of file kpty.cpp.

void KPty::setCTty ( )

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

Definition at line 474 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
echotrue if input should be echoed.
Returns
true on success, false otherwise

Definition at line 677 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
linesthe number of rows
columnsthe number of columns
Returns
true on success, false otherwise

Definition at line 666 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 703 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
ttmodea 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 646 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
ttmodea 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 656 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 689 of file kpty.cpp.

Member Data Documentation

KPtyPrivate* const KPty::d_ptr
protected

Definition at line 201 of file kpty.h.


The documentation for this class was generated from the following files:
  • kpty.h
  • kpty.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:48:56 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KPty

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal