On Windows, the "nul" special path must be used instead of
"/dev/null".
Worth mentioning that reading from "nul" will report errors, unlike
"/dev/null" on POSIX platforms. This doesn't affect writes.
Signed-off-by: Lucian Petrut <lpetrut@cloudbasesolutions.com>
int reopen_as_null(CephContext *cct, int fd)
{
- int newfd = open("/dev/null", O_RDONLY|O_CLOEXEC);
+ int newfd = open(DEV_NULL, O_RDONLY | O_CLOEXEC);
if (newfd < 0) {
int err = errno;
lderr(cct) << __func__ << " failed to open /dev/null: " << cpp_strerror(err)
#define O_CLOEXEC 0
#define SOCKOPT_VAL_TYPE char*
+#define DEV_NULL "nul"
+
#else /* WIN32 */
#define SOCKOPT_VAL_TYPE void*
return close(fildes);
}
+#define DEV_NULL "/dev/null"
+
#endif /* WIN32 */
/* Supplies code to be run at startup time before invoking main().