windows: msvc: Define STDIN/OUT/ERR_FILENO.
authorAndres Freund <andres@anarazel.de>
Tue, 19 Jul 2022 00:06:34 +0000 (17:06 -0700)
committerAndres Freund <andres@anarazel.de>
Tue, 19 Jul 2022 00:21:54 +0000 (17:21 -0700)
Because they are not available we've used _fileno(stdin) in some places, but
that doesn't reliably work, because stdin might be closed. This is the
prerequisite of the subsequent commit, fixing a failure introduced in
76e38b37a5.

Author: Andres Freund <andres@anarazel.de>
Reported-By: Sandeep Thakkar <sandeep.thakkar@enterprisedb.com>
Message-Id: 20220520164558.ozb7lm6unakqzezi@alap3.anarazel.de (on pgsql-packagers)
Backpatch: 15-, where 76e38b37a5 came in

src/include/port/win32_msvc/unistd.h

index b63f4770a1c9a0738d3f08a863baf4f908fd8847..b7795ba03c4ed146f0d87445d6d3da878aabf37d 100644 (file)
@@ -1 +1,9 @@
 /* src/include/port/win32_msvc/unistd.h */
+
+/*
+ * MSVC does not define these, nor does _fileno(stdin) etc reliably work
+ * (returns -1 if stdin/out/err are closed).
+ */
+#define STDIN_FILENO   0
+#define STDOUT_FILENO  1
+#define STDERR_FILENO  2