subprocess::idescriptor class

Adds read ability to descriptor.

Additionally, the class is marked closable. All input descriptors inherit from this class.

Base classes

class descriptor virtual
Abstracts file descriptors.

Derived classes

class ifile_descriptor virtual
Always opens the file in read-mode.
class ipipe_descriptor
A descriptor wrapping the input end of a posix OS pipe.

Constructors, destructors, conversion operators

descriptor() defaulted
descriptor(int fd) explicit
descriptor(const descriptor&) defaulted
descriptor(descriptor&&) defaulted noexcept

Public functions

auto read() -> std::string virtual
Read from fd and return std::string.
void close() override
Tear down the descriptor.
auto closable() const -> bool override
Marks whether the subprocess should close the FD.

Function documentation

std::string subprocess::idescriptor::read() virtual

Read from fd and return std::string.

Returns std::string Contents of fd

void subprocess::idescriptor::close() override

Tear down the descriptor.

close() is called by subprocess::execute() after the process is spawned, but before waiting. This should ideally be the place where you should tear down the constructs that were required for process I/O.

bool subprocess::idescriptor::closable() const override

Marks whether the subprocess should close the FD.

Returns true The subprocess should close the FD