Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY, utmp registration and setting various terminal attributes. More...
#include "kpty.h"
Public Member Functions | |
KPty () | |
Constructor. More... | |
KPty (int masterFd, int slaveFd) | |
~KPty () | |
Destructor: More... | |
void | close () |
Close the pty master/slave pair. More... | |
void | closeSlave () |
Close the pty slave descriptor. More... | |
int | masterFd () const |
bool | open () |
Create a pty master/slave pair. More... | |
bool | setEcho (bool echo) |
Set whether the pty should echo input. More... | |
bool | setWinSize (int lines, int columns) |
Change the logical (screen) size of the pty. More... | |
int | slaveFd () const |
bool | tcGetAttr (struct ::termios *ttmode) const |
Wrapper around tcgetattr(3). More... | |
bool | tcSetAttr (struct ::termios *ttmode) |
Wrapper around tcsetattr(3) with mode TCSANOW. More... | |
const char * | ttyName () const |
Protected Member Functions | |
KPty (KPtyPrivate *d) | |
Protected Attributes | |
KPtyPrivate *const | d_ptr |
Provides primitives for opening & closing a pseudo TTY pair, assigning the controlling TTY, utmp registration and setting various terminal attributes.
KPty::~KPty | ( | ) |
|
protected |
Definition at line 203 of file kpty.cpp.
References d_ptr, and KPtyPrivate::q_ptr.
void KPty::close | ( | void | ) |
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 396 of file kpty.cpp.
Referenced by close().
int KPty::masterFd | ( | ) | const |
This function should be called only while the pty is open.
Definition at line 482 of file kpty.cpp.
References d.
Referenced by TerminalModel::TerminalModel(), and TerminalModel::sendData().
bool KPty::open | ( | ) |
Create a pty master/slave pair.
Definition at line 215 of file kpty.cpp.
References close(), d, fcntl(), geteuid(), getgid(), group::getgrnam(), getuid(), group::gid(), PATH_MAX, stat(), tcGetAttr(), tcSetAttr(), and TTY_GROUP.
Referenced by QUnixTerminalImpl::initialize().
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.
echo | true if input should be echoed. |
true
on success, false otherwise Definition at line 463 of file kpty.cpp.
References ECHO, tcGetAttr(), and tcSetAttr().
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.
lines | the number of rows |
columns | the number of columns |
true
on success, false otherwise Definition at line 452 of file kpty.cpp.
References d.
Referenced by TerminalModel::updateTerminalSize().
int KPty::slaveFd | ( | ) | const |
This function should be called only while the pty slave is open.
Definition at line 489 of file kpty.cpp.
References d.
Referenced by QUnixTerminalImpl::connectToPty().
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.
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. |
true
on success, false otherwise Definition at line 438 of file kpty.cpp.
References d.
bool KPty::tcSetAttr | ( | struct ::termios * | ttmode | ) |
Wrapper around tcsetattr(3) with mode TCSANOW.
This function can be used only while the PTY is open.
ttmode | a pointer to a termios structure. |
true
on success, false otherwise. Note that success means that at least one attribute could be set. Definition at line 445 of file kpty.cpp.
References d.
const char * KPty::ttyName | ( | ) | const |
|
protected |