aboutsummaryrefslogtreecommitdiff
path: root/butl/fdstream.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'butl/fdstream.cxx')
-rw-r--r--butl/fdstream.cxx16
1 files changed, 15 insertions, 1 deletions
diff --git a/butl/fdstream.cxx b/butl/fdstream.cxx
index d99be70..13becfa 100644
--- a/butl/fdstream.cxx
+++ b/butl/fdstream.cxx
@@ -5,9 +5,11 @@
#include <butl/fdstream>
#ifndef _WIN32
+# include <fcntl.h> // open(), O_RDWR
# include <unistd.h> // close(), read(), write()
#else
-# include <io.h> // _close(), _read(), _write(), _setmode()
+# include <io.h> // _close(), _read(), _write(), _setmode(), _sopen()
+# include <share.h> // _SH_DENYNO
# include <stdio.h> // _fileno(), stdin, stdout, stderr
# include <fcntl.h> // _O_BINARY, _O_TEXT
#endif
@@ -153,6 +155,12 @@ namespace butl
return close (fd) == 0;
}
+ int
+ fdnull () noexcept
+ {
+ return open ("/dev/null", O_RDWR);
+ }
+
fdtranslate
fdmode (int, fdtranslate)
{
@@ -185,6 +193,12 @@ namespace butl
return _close (fd) == 0;
}
+ int
+ fdnull () noexcept
+ {
+ return _sopen ("nul", _O_RDWR, _SH_DENYNO);
+ }
+
fdtranslate
fdmode (int fd, fdtranslate m)
{