Skip site navigation (1) Skip section navigation (2)

Re: dup(0) failed after 3195 successes: Bad file descriptor

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Martijn van Oosterhout <kleptog(at)svana(dot)org>
Cc: CSN <cool_screen_name90001(at)yahoo(dot)com>,pgsql-general(at)postgresql(dot)org, pgsql-hackers-win32(at)postgresql(dot)org
Subject: Re: dup(0) failed after 3195 successes: Bad file descriptor
Date: 2004-06-30 03:31:07
Message-ID: 3177.1088566267@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-generalpgsql-hackers-win32
Martijn van Oosterhout <kleptog(at)svana(dot)org> writes:
> On Tue, Jun 29, 2004 at 10:10:18AM -0400, Tom Lane wrote:
>> Hmm.  What system is this on?  What errno code corresponds to
>> "Bad file descriptor"?

> That would be EBADF I think. However, my linux manpage indicates it's
> not a possible return from dup, only from dup2. Very odd.

HPUX man page says that it's a valid dup() error when the *supplied*
descriptor is bogus.  Which is surely not true for zero (stdin) and
is even less plausible given that the previous 3195 iterations of this
tight loop had no problem with the same supplied descriptor.

But CSN says in a followup that this is on Cygwin.  In short, what we
got here is another Cygwin bug [yawn].  I'm inclined to do something
like

        if (thisfd < 0)
        {
            /*
             * Expect EMFILE or ENFILE, else it's fishy; and Cygwin has
             * a fishiness level all of its own...
             */
            if (errno != EMFILE && errno != ENFILE
#ifdef __CYGWIN__
                && errno != EBADF
#endif
               )
                elog(WARNING, "dup(0) failed after %d successes: %m", used);
            break;
        }

unless someone can point to another platform that does the same thing.
(Hey -win32 hackers: does the native port exhibit this behavior?)

			regards, tom lane

In response to

pgsql-hackers-win32 by date

Next:From: 帅猛Date: 2004-06-30 07:24:42
Subject: make errors
Previous:From: 帅猛Date: 2004-06-30 02:19:23
Subject: build win32 with mingw and msys

pgsql-general by date

Next:From: Tom LaneDate: 2004-06-30 04:19:42
Subject: Re: postgresql install: jdbc: No such file or directory.
Previous:From: Tom LaneDate: 2004-06-30 02:50:56
Subject: Re: query failing with out of memory error message.

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group