|
RADLib
RADical C++ application framework
|
PTY-backed process helper for terminal applications. More...
#include <RADCore.h>
Inheritance diagram for RADCore::RADPtyProcess:
Collaboration diagram for RADCore::RADPtyProcess:Public Member Functions | |
| RADPtyProcess () | |
| Creates a non-running PTY process. More... | |
| ~RADPtyProcess () override | |
| Stops and cleans up the PTY process if needed. More... | |
| bool | start (const std::string &program={}, const std::vector< std::string > &arguments={}, uint16_t rows=30, uint16_t columns=120) |
| Starts program in a PTY; empty program selects the user's shell. More... | |
| bool | waitForFinished (int timeoutMs=-1) |
| Waits for process exit; timeoutMs < 0 waits indefinitely. More... | |
| void | kill () |
| Sends a kill request to the child. More... | |
| void | close () |
| Closes the PTY handle. More... | |
| ssize_t | readData (void *buffer, size_t maxBytes) |
| Reads bytes from the PTY. More... | |
| ssize_t | writeData (const void *data, size_t size) |
| Writes bytes to the PTY. More... | |
| ssize_t | write (const std::string &text) |
| Writes string bytes to the PTY. More... | |
| bool | resizeTerminal (uint16_t rows, uint16_t columns) |
| Resizes the PTY terminal dimensions. More... | |
| ProcessState | state () const |
| Returns process state. More... | |
| int | exitCode () const |
| Returns exit code after finish. More... | |
Public Member Functions inherited from RADCore::RADObject | |
| RADObject () | |
| Creates a RADObject bound to the current thread. More... | |
| virtual | ~RADObject () |
| Disconnects tracked event links and releases lifetime token. More... | |
| void | registerLink (const ConnectionRecord &record) |
| Registers a connection for cleanup when this object is destroyed. More... | |
| std::thread::id | threadId () const |
| Returns the thread id this object is currently associated with. More... | |
| EventLoop * | associatedEventLoop () const |
| Returns the associated event loop, if any. More... | |
| ThreadAffinity | threadAffinity () const |
| Returns both thread id and associated loop atomically. More... | |
| std::weak_ptr< void > | lifetimeToken () const |
| Returns a weak token used to drop queued callbacks after destruction. More... | |
| void | moveToThread (std::thread::id tId, EventLoop *loop=nullptr) |
| Moves the object's affinity to tId and optional loop. More... | |
Public Attributes | |
| RADCore::Event< void() > | started |
| Raised when the child starts. More... | |
| RADCore::Event< void(int) > | finished |
| Raised with exit code when the child exits. More... | |
| RADCore::Event< void(std::string) > | errorOccurred |
| Raised when PTY/process operations fail. More... | |
PTY-backed process helper for terminal applications.
| RADCore::RADPtyProcess::RADPtyProcess | ( | ) |
Creates a non-running PTY process.
|
override |
Stops and cleans up the PTY process if needed.
| void RADCore::RADPtyProcess::close | ( | ) |
Closes the PTY handle.
| int RADCore::RADPtyProcess::exitCode | ( | ) | const |
Returns exit code after finish.
| void RADCore::RADPtyProcess::kill | ( | ) |
Sends a kill request to the child.
| ssize_t RADCore::RADPtyProcess::readData | ( | void * | buffer, |
| size_t | maxBytes | ||
| ) |
Reads bytes from the PTY.
| bool RADCore::RADPtyProcess::resizeTerminal | ( | uint16_t | rows, |
| uint16_t | columns | ||
| ) |
Resizes the PTY terminal dimensions.
| bool RADCore::RADPtyProcess::start | ( | const std::string & | program = {}, |
| const std::vector< std::string > & | arguments = {}, |
||
| uint16_t | rows = 30, |
||
| uint16_t | columns = 120 |
||
| ) |
Starts program in a PTY; empty program selects the user's shell.
| ProcessState RADCore::RADPtyProcess::state | ( | ) | const |
Returns process state.
| bool RADCore::RADPtyProcess::waitForFinished | ( | int | timeoutMs = -1 | ) |
Waits for process exit; timeoutMs < 0 waits indefinitely.
| ssize_t RADCore::RADPtyProcess::write | ( | const std::string & | text | ) |
Writes string bytes to the PTY.
| ssize_t RADCore::RADPtyProcess::writeData | ( | const void * | data, |
| size_t | size | ||
| ) |
Writes bytes to the PTY.
| RADCore::Event<void (std::string) > RADCore::RADPtyProcess::errorOccurred |
Raised when PTY/process operations fail.
| RADCore::Event<void (int) > RADCore::RADPtyProcess::finished |
Raised with exit code when the child exits.
| RADCore::Event<void () > RADCore::RADPtyProcess::started |
Raised when the child starts.