From c326c636c394b6b8c2ea170bafb89e7a00d8e828 Mon Sep 17 00:00:00 2001 From: Christopher Dykes Date: Wed, 10 Aug 2016 12:35:31 -0700 Subject: [PATCH] Special-case /dev/null in open in the portability header Summary: `/dev/null` doesn't exist on Windows, but thankfully, `NUL` does, and has the same semantics. Reviewed By: meyering Differential Revision: D3698007 fbshipit-source-id: 5ef31c6576f988dd747ea3c39e296c244bc640b7 --- folly/portability/Fcntl.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/folly/portability/Fcntl.cpp b/folly/portability/Fcntl.cpp index 015f4a6d..9cbfa5bf 100755 --- a/folly/portability/Fcntl.cpp +++ b/folly/portability/Fcntl.cpp @@ -96,6 +96,11 @@ int open(char const* fn, int of, int pm) { // none are. return -1; } + if (!strcmp(fn, "/dev/null")) { + // Windows doesn't have a /dev/null, but it does have + // NUL, which achieves the same result. + fn = "NUL"; + } errno_t res = _sopen_s(&fh, fn, of, _SH_DENYNO, realMode); return res ? -1 : fh; } -- 2.34.1