pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Mario Emmenlauer <mario@emmenlauer.de>
Cc: pgsql-hackers@lists.postgresql.org
Subject: Re: dup(0) fails on Ubuntu 20.04 and macOS 10.15 with 13.0
Date: Wed, 01 Sep 2021 09:54:46 -0400
Message-ID: <2071112.1630504486@sss.pgh.pa.us> (raw)
In-Reply-To: <1c4c2254-1812-2913-8630-18d4b9262a89@emmenlauer.de>
References: <48bafc63-c30f-3962-2ded-f2e985d93e86@emmenlauer.de>
	<3ac84ee7-b4a0-aba5-ddb5-b7c0811fc754@emmenlauer.de>
	<f6b36e1b-cd28-487a-99da-3d7ca772baff@emmenlauer.de>
	<1c4c2254-1812-2913-8630-18d4b9262a89@emmenlauer.de>

[ redirecting to -hackers ]

Mario Emmenlauer <mario@emmenlauer.de> writes:
> On 05.10.20 14:35, Tom Lane wrote:
>> Mario Emmenlauer <mario@emmenlauer.de> writes:
>>> I get reproducibly the error:
>>> 2020-10-05 11:48:19.720 CEST [84731] WARNING:  dup(0) failed after 0 successes: Bad file descriptor

>> Hmph.  That code loop assumes that stdin exists to be duplicated,
>> but maybe if it had been closed, you'd get this error.
>> 
>> However, that logic hasn't changed in decades, and we've not heard
>> complaints about it before.  Are you starting the server in some
>> unusual way?

> Replying to a very old thread here: I could indeed trace the problem of
> the failing `dup(0)` back to how we start the server! We start the
> server from an executable that closes stdin very early on, and this
> seems to lead to the problem.
> We solved it by not closing stdin. But for future reference, if other
> people may be affected by this, the code could probably be modified to
> revert to stdout or stderr or a temporary file in case stdin is not
> available (guessing here...).

Hm.  I'm tempted to propose that we simply change that from dup(0) to
dup(2).  Formally, that's just moving the problem around.  In practice
though, there are good reasons not to close the server's stderr, ie you
will lose error messages that might be important.  OTOH there does not
seem to be any obvious reason why the server should need valid stdin,
so if we can get rid of an implementation artifact that makes it require
that, that seems like an improvement.

			regards, tom lane





view thread (10+ messages)  latest in thread

Message-ID: <2071112.1630504486@sss.pgh.pa.us>
Permalink:  ../2071112.1630504486@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/2071112.1630504486@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: tgl@sss.pgh.pa.us, mario@emmenlauer.de, pgsql-hackers@lists.postgresql.org
  Subject: Re: dup(0) fails on Ubuntu 20.04 and macOS 10.15 with 13.0
  In-Reply-To: <2071112.1630504486@sss.pgh.pa.us>
  References: <48bafc63-c30f-3962-2ded-f2e985d93e86@emmenlauer.de> <3ac84ee7-b4a0-aba5-ddb5-b7c0811fc754@emmenlauer.de> <f6b36e1b-cd28-487a-99da-3d7ca772baff@emmenlauer.de> <1c4c2254-1812-2913-8630-18d4b9262a89@emmenlauer.de> <2071112.1630504486@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox