From 06950aab233de6a2f47293d59575bb42f6131660 Mon Sep 17 00:00:00 2001 From: Joel Klinghed Date: Wed, 27 Jan 2021 22:06:49 +0100 Subject: Complete rewrite using C++ and with shared state support --- src/unique_fd.cc | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/unique_fd.cc (limited to 'src/unique_fd.cc') diff --git a/src/unique_fd.cc b/src/unique_fd.cc new file mode 100644 index 0000000..a289f0e --- /dev/null +++ b/src/unique_fd.cc @@ -0,0 +1,17 @@ +#include "common.hh" + +#include "unique_fd.hh" + +#include + +void unique_fd::reset(int fd) { + if (fd_ >= 0) + close(fd_); + fd_ = fd; +} + +unique_fd unique_fd::dup() { + if (fd_ >= 0) + return unique_fd(::dup(fd_)); + return unique_fd(); +} -- cgit v1.2.3-70-g09d2