NPRPC docs

class UniqueFd

C++

class UniqueFd

An owned file descriptor: closed when the owner goes away.

The C++ type of the IDL fd. A servant receives one by value and owns it; a proxy returns one for an out or return value. An in argument is a plain int borrowed for the duration of the call: the runtime duplicates it, so the caller's descriptor is left as it was.

Only a transport that can carry descriptors between processes can send one. Calling a method with an fd over any other throws before anything is sent.

include/nprpc/unique_fd.hpp:24

Constructors

UniqueFd() noexcept = default

No descriptor.

include/nprpc/unique_fd.hpp:30

explicit UniqueFd(int fd) noexcept

Takes ownership of fd.

include/nprpc/unique_fd.hpp:32

UniqueFd(UniqueFd &&other) noexcept

Not documented.

include/nprpc/unique_fd.hpp:37

Methods

static UniqueFd dup(int fd)

A close-on-exec duplicate of fd, which stays open and stays the caller's. Empty if fd is negative; throws std::system_error if the duplicate cannot be made.

include/nprpc/unique_fd.hpp:57

int get() const noexcept

The descriptor, still owned; -1 if none.

include/nprpc/unique_fd.hpp:60

int release() noexcept

Gives up ownership without closing.

include/nprpc/unique_fd.hpp:65

void reset(int fd = -1) noexcept

Closes the current descriptor, if any, and takes fd.

include/nprpc/unique_fd.hpp:68

bool valid() const noexcept

Not documented.

include/nprpc/unique_fd.hpp:61

Operators

explicit operator bool() const noexcept

Not documented.

include/nprpc/unique_fd.hpp:62

UniqueFd &operator=(UniqueFd &&other) noexcept

Not documented.

include/nprpc/unique_fd.hpp:42