26 operator=(std::forward<UnixFD>(other));
29 UnixFD::~UnixFD() noexcept {
reset(); }
59 int nfd = ::fcntl(fd, F_DUPFD_CLOEXEC, min);
62 throw std::runtime_error(
"Failed to dup file descriptor");
76 }
while (ret == -1 && errno == EINTR);
Class wrap around the unix fd.
bool isValid() const noexcept
Check if fd is not empty.
UnixFD() noexcept
Create an empty UnixFD.
Utility class to handle unix file decriptor.
int fd() const noexcept
Get the internal fd.
void reset() noexcept
Clear the FD and close it.
void set(int fd)
Set a new FD.
void give(int fd) noexcept
Set a new FD and transfer the ownership to UnixFD.
int release() noexcept
Get the internal fd and release the ownership.