KPtyProcess

#include <kptyprocess.h>

Inheritance diagram for KPtyProcess:

Public Types

enum  PtyChannelFlag {
  NoChannels = 0, StdinChannel = 1, StdoutChannel = 2, StderrChannel = 4,
  AllOutputChannels = 6, AllChannels = 7
}
 
typedef QFlags< PtyChannelFlagPtyChannels
 
- Public Types inherited from KProcess
enum  OutputChannelMode
 
- Public Types inherited from QProcess
enum  ExitStatus
 
enum  InputChannelMode
 
enum  ProcessChannel
 
enum  ProcessChannelMode
 
enum  ProcessError
 
enum  ProcessState
 
- Public Types inherited from QIODevice
enum  OpenModeFlag
 

Public Member Functions

 KPtyProcess (QObject *parent=nullptr)
 
 KPtyProcess (int ptyMasterFd, QObject *parent=nullptr)
 
 ~KPtyProcess () override
 
bool isUseUtmp () const
 
KPtyDevicepty () const
 
PtyChannels ptyChannels () const
 
void setPtyChannels (PtyChannels channels)
 
void setUseUtmp (bool value)
 
- Public Member Functions inherited from KProcess
 KProcess (QObject *parent=nullptr)
 
void clearEnvironment ()
 
void clearProgram ()
 
int execute (int msecs=-1)
 
KProcessoperator<< (const QString &arg)
 
KProcessoperator<< (const QStringList &args)
 
OutputChannelMode outputChannelMode () const
 
int pid () const
 
QStringList program () const
 
void setEnv (const QString &name, const QString &value, bool overwrite=true)
 
void setNextOpenMode (QIODevice::OpenMode mode)
 
void setOutputChannelMode (OutputChannelMode mode)
 
void setProgram (const QString &exe, const QStringList &args=QStringList())
 
void setProgram (const QStringList &argv)
 
void setShellCommand (const QString &cmd)
 
void start ()
 
int startDetached ()
 
void unsetEnv (const QString &name)
 
- Public Member Functions inherited from QProcess
 QProcess (QObject *parent)
 
QStringList arguments () const const
 
virtual bool atEnd () const const override
 
virtual qint64 bytesAvailable () const const override
 
virtual qint64 bytesToWrite () const const override
 
virtual bool canReadLine () const const override
 
virtual void close () override
 
void closeReadChannel (QProcess::ProcessChannel channel)
 
void closeWriteChannel ()
 
QProcess::CreateProcessArgumentModifier createProcessArgumentsModifier () const const
 
QStringList environment () const const
 
QProcess::ProcessError error () const const
 
void error (QProcess::ProcessError error)
 
void errorOccurred (QProcess::ProcessError error)
 
int exitCode () const const
 
QProcess::ExitStatus exitStatus () const const
 
void finished (int exitCode)
 
void finished (int exitCode, QProcess::ExitStatus exitStatus)
 
QProcess::InputChannelMode inputChannelMode () const const
 
virtual bool isSequential () const const override
 
void kill ()
 
QString nativeArguments () const const
 
virtual bool open (QIODevice::OpenMode mode) override
 
Q_PID pid () const const
 
QProcess::ProcessChannelMode processChannelMode () const const
 
QProcessEnvironment processEnvironment () const const
 
qint64 processId () const const
 
QString program () const const
 
 QT_NO_PROCESS_COMBINED_ARGUMENT_START QT_NO_PROCESS_COMBINED_ARGUMENT_START
 
QByteArray readAllStandardError ()
 
QByteArray readAllStandardOutput ()
 
QProcess::ProcessChannel readChannel () const const
 
QProcess::ProcessChannelMode readChannelMode () const const
 
void readyReadStandardError ()
 
void readyReadStandardOutput ()
 
void setArguments (const QStringList &arguments)
 
void setCreateProcessArgumentsModifier (QProcess::CreateProcessArgumentModifier modifier)
 
void setEnvironment (const QStringList &environment)
 
void setInputChannelMode (QProcess::InputChannelMode mode)
 
void setNativeArguments (const QString &arguments)
 
void setProcessChannelMode (QProcess::ProcessChannelMode mode)
 
void setProcessEnvironment (const QProcessEnvironment &environment)
 
void setProgram (const QString &program)
 
void setReadChannel (QProcess::ProcessChannel channel)
 
void setReadChannelMode (QProcess::ProcessChannelMode mode)
 
void setStandardErrorFile (const QString &fileName, QIODevice::OpenMode mode)
 
void setStandardInputFile (const QString &fileName)
 
void setStandardOutputFile (const QString &fileName, QIODevice::OpenMode mode)
 
void setStandardOutputProcess (QProcess *destination)
 
void setWorkingDirectory (const QString &dir)
 
void start (const QString &command, QIODevice::OpenMode mode)
 
void start (QIODevice::OpenMode mode)
 
void start (const QString &program, const QStringList &arguments, QIODevice::OpenMode mode)
 
bool startDetached (qint64 *pid)
 
void started ()
 
QProcess::ProcessState state () const const
 
void stateChanged (QProcess::ProcessState newState)
 
void terminate ()
 
virtual bool waitForBytesWritten (int msecs) override
 
bool waitForFinished (int msecs)
 
virtual bool waitForReadyRead (int msecs) override
 
bool waitForStarted (int msecs)
 
QString workingDirectory () const const
 
- Public Member Functions inherited from QIODevice
 QIODevice (QObject *parent)
 
void aboutToClose ()
 
void bytesWritten (qint64 bytes)
 
void channelBytesWritten (int channel, qint64 bytes)
 
void channelReadyRead (int channel)
 
void commitTransaction ()
 
int currentReadChannel () const const
 
int currentWriteChannel () const const
 
QString errorString () const const
 
bool getChar (char *c)
 
bool isOpen () const const
 
bool isReadable () const const
 
bool isTextModeEnabled () const const
 
bool isTransactionStarted () const const
 
bool isWritable () const const
 
QIODevice::OpenMode openMode () const const
 
qint64 peek (char *data, qint64 maxSize)
 
QByteArray peek (qint64 maxSize)
 
virtual qint64 pos () const const
 
bool putChar (char c)
 
qint64 read (char *data, qint64 maxSize)
 
QByteArray read (qint64 maxSize)
 
QByteArray readAll ()
 
int readChannelCount () const const
 
void readChannelFinished ()
 
QByteArray readLine (qint64 maxSize)
 
qint64 readLine (char *data, qint64 maxSize)
 
void readyRead ()
 
virtual bool reset ()
 
void rollbackTransaction ()
 
virtual bool seek (qint64 pos)
 
void setCurrentReadChannel (int channel)
 
void setCurrentWriteChannel (int channel)
 
void setTextModeEnabled (bool enabled)
 
virtual qint64 size () const const
 
qint64 skip (qint64 maxSize)
 
void startTransaction ()
 
void ungetChar (char c)
 
qint64 write (const char *data)
 
qint64 write (const QByteArray &byteArray)
 
qint64 write (const char *data, qint64 maxSize)
 
int writeChannelCount () const const
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo ()
 
void dumpObjectInfo () const const
 
void dumpObjectTree ()
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegExp &regExp, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_DISABLE_COPY (Class)
 
 Q_DISABLE_COPY_MOVE (Class)
 
 Q_DISABLE_MOVE (Class)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qFindChild (const QObject *obj, const QString &name)
 
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
 
QList< T > qFindChildren (const QObject *obj, const QString &name)
 
qobject_cast (QObject *object)
 
qobject_cast (const QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds time, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

void setupChildProcess () override
 
- Protected Member Functions inherited from KProcess
 KProcess (KProcessPrivate *d, QObject *parent)
 
- Protected Member Functions inherited from QProcess
virtual qint64 readData (char *data, qint64 maxlen) override
 
void setProcessState (QProcess::ProcessState state)
 
virtual qint64 writeData (const char *data, qint64 len) override
 
- Protected Member Functions inherited from QIODevice
virtual qint64 readLineData (char *data, qint64 maxSize)
 
void setErrorString (const QString &str)
 
void setOpenMode (QIODevice::OpenMode openMode)
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from KProcess
static int execute (const QString &exe, const QStringList &args=QStringList(), int msecs=-1)
 
static int execute (const QStringList &argv, int msecs=-1)
 
static int startDetached (const QString &exe, const QStringList &args=QStringList())
 
static int startDetached (const QStringList &argv)
 
- Static Public Member Functions inherited from QProcess
int execute (const QString &program, const QStringList &arguments)
 
int execute (const QString &command)
 
QString nullDevice ()
 
QStringList splitCommand (QStringView command)
 
bool startDetached (const QString &command)
 
bool startDetached (const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid)
 
QStringList systemEnvironment ()
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Public Attributes inherited from KProcess
 ForwardedChannels
 
 MergedChannels
 
 OnlyStderrChannel
 
 OnlyStdoutChannel
 
 SeparateChannels
 
- Public Attributes inherited from QProcess
 Crashed
 
 CrashExit
 
typedef CreateProcessArgumentModifier
 
 FailedToStart
 
 ForwardedChannels
 
 ForwardedErrorChannel
 
 ForwardedInputChannel
 
 ForwardedOutputChannel
 
 ManagedInputChannel
 
 MergedChannels
 
 NormalExit
 
 NotRunning
 
typedef Q_PID
 
 ReadError
 
 Running
 
 SeparateChannels
 
 StandardError
 
 StandardOutput
 
 Starting
 
 Timedout
 
 UnknownError
 
 WriteError
 
- Public Attributes inherited from QIODevice
 Append
 
 ExistingOnly
 
 NewOnly
 
 NotOpen
 
typedef OpenMode
 
 ReadOnly
 
 ReadWrite
 
 Text
 
 Truncate
 
 Unbuffered
 
 WriteOnly
 
- Public Attributes inherited from QObject
typedef QObjectList
 
- Protected Attributes inherited from KProcess
KProcessPrivate *const d_ptr
 

Detailed Description

This class extends KProcess by support for PTYs (pseudo TTYs).

The PTY is opened as soon as the class is instantiated. Verify that it was opened successfully by checking that pty()->masterFd() is not -1.

The PTY is always made the process' controlling TTY. Utmp registration and connecting the stdio handles to the PTY are optional.

No attempt to integrate with QProcess' waitFor*() functions was made, for it is impossible. Note that execute() does not work with the PTY, too. Use the PTY device's waitFor*() functions or use it asynchronously.

Author
Oswald Buddenhagen [email protected][email protected]kde.[email protected]org

Definition at line 34 of file kptyprocess.h.

Member Typedef Documentation

Stores a combination of PtyChannelFlag values.

Definition at line 55 of file kptyprocess.h.

Member Enumeration Documentation

See also
PtyChannels
Enumerator
NoChannels 

The PTY is not connected to any channel.

StdinChannel 

Connect PTY to stdin.

StdoutChannel 

Connect PTY to stdout.

StderrChannel 

Connect PTY to stderr.

AllOutputChannels 

Connect PTY to all output channels.

AllChannels 

Connect PTY to all channels.

Definition at line 43 of file kptyprocess.h.

Constructor & Destructor Documentation

KPtyProcess::KPtyProcess ( QObject parent = nullptr)
explicit

Constructor.

Definition at line 40 of file kptyprocess.cpp.

KPtyProcess::KPtyProcess ( int  ptyMasterFd,
QObject parent = nullptr 
)

Construct a process using an open pty master.

Parameters
ptyMasterFdan open pty master file descriptor. The process does not take ownership of the descriptor; it will not be automatically closed at any point.

Definition at line 51 of file kptyprocess.cpp.

KPtyProcess::~KPtyProcess ( )
override

Destructor.

Definition at line 62 of file kptyprocess.cpp.

Member Function Documentation

bool KPtyProcess::isUseUtmp ( ) const

Get whether to register the process as a TTY login in utmp.

Returns
whether to register in utmp

Definition at line 96 of file kptyprocess.cpp.

KPtyDevice * KPtyProcess::pty ( ) const

Get the PTY device of this process.

Returns
the PTY device

Definition at line 103 of file kptyprocess.cpp.

KPtyProcess::PtyChannels KPtyProcess::ptyChannels ( ) const

Query to which channels the PTY is assigned.

Returns
the output channel handling mode

Definition at line 82 of file kptyprocess.cpp.

void KPtyProcess::setPtyChannels ( PtyChannels  channels)

Set to which channels the PTY should be assigned.

This function must be called before starting the process.

Parameters
channelsthe output channel handling mode

Definition at line 75 of file kptyprocess.cpp.

void KPtyProcess::setupChildProcess ( )
overrideprotectedvirtual
Reimplemented from superclass.

Reimplemented from QProcess.

Definition at line 110 of file kptyprocess.cpp.

void KPtyProcess::setUseUtmp ( bool  value)

Set whether to register the process as a TTY login in utmp.

Utmp is disabled by default. It should enabled for interactively fed processes, like terminal emulations.

This function must be called before starting the process.

Parameters
valuewhether to register in utmp.

Definition at line 89 of file kptyprocess.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Tue Jul 14 2020 22:52:30 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.