aboutsummaryrefslogtreecommitdiff
path: root/src/backend/storage/file/fd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/storage/file/fd.c')
-rw-r--r--src/backend/storage/file/fd.c8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c
index 433e2832a54..f9cda6906d2 100644
--- a/src/backend/storage/file/fd.c
+++ b/src/backend/storage/file/fd.c
@@ -934,7 +934,9 @@ InitTemporaryFileAccess(void)
* of already_open will give the right answer. In practice, max_to_probe
* of a couple of dozen should be enough to ensure good results.
*
- * We assume stdin (FD 0) is available for dup'ing
+ * We assume stderr (FD 2) is available for dup'ing. While the calling
+ * script could theoretically close that, it would be a really bad idea,
+ * since then one risks loss of error messages from, e.g., libc.
*/
static void
count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
@@ -978,12 +980,12 @@ count_usable_fds(int max_to_probe, int *usable_fds, int *already_open)
break;
#endif
- thisfd = dup(0);
+ thisfd = dup(2);
if (thisfd < 0)
{
/* Expect EMFILE or ENFILE, else it's fishy */
if (errno != EMFILE && errno != ENFILE)
- elog(WARNING, "dup(0) failed after %d successes: %m", used);
+ elog(WARNING, "duplicating stderr file descriptor failed after %d successes: %m", used);
break;
}