kernel patch for "Can't open display" - also fixes CVS problem The descriptor is a file, not a socket

Paul Gresham
Thu Jun 21 12:06:00 GMT 2001

Mark, thanks very much, it works fine, I think that patch needs to get
into the main cygwin tree asap, as you  have also fixed all my problems
with cvs under cygwin on WinME. Thanks again. There are a lot of posts
for the past few versions of Cygwin regarding the CVS problem, hence the
cross-post and full quote of your message.


To all that receive the "Can't open display" message for your X clients.

If this is not related to the DISPLAY variable, and other obvious
problems, then this kernel patch may help you.  I just hacked this
together last night, so YMMV, but for the brave you can download a new
cygwin1.dll from my site at:

Copy this cygwin1.dll into /bin for the latest release of cygwin.  It
works for me, but no assurances about your results.  Here is a
description of the problem.  This description pertains to the
winsup/cygwin portion of the cygwin kernel.

Inside of the client code for X applications, you will find a fcntl
F_SETFD.  By default the file for the kernel passes
this to  Inside of the F_SETFD gets passed to
"set_close_on_exec(...)".  This then calls set_inheritence(..), which
this ominous line in it:

/* FIXME: This won't work with sockets */
 ForceCloseHandle2(h, name);

Anyway, needless to say, the problem has to do with the duplicate handle

not being valid for subsequent socket calls.

A "fix" that I implemented is to disable the close_on_exec support for
sockets only.  Inside of , edit the fcntl(..)
and add this to the switch statement:

 case    F_SETFD:
  // the default handler is broken for now
  // should send -1 but have to lie to vtwm so send 0
  res = 0;

After I did this, X starts up great and everything is fine except I miss

my KDE ;-)

Of course, your mileage may vary, and I advise that this bug be sent to
the real developers of the cygwin kernel so they can fix it properly.
This should be considered a temporary work around!

-Mark Oskin

Want to unsubscribe from this list?
Check out:

More information about the Cygwin mailing list