[winGRASS] Re: [GRASS5] Windows native Xdriver

Glynn Clements glynn.clements at virgin.net
Wed May 1 21:16:12 EDT 2002


Mike Thomas wrote:

> > I've committed a change which uses /dev/windows. This works at first,
> > but eventually XDRIVER dies. I'd appreciate feedback on what happens
> > on NT/2K/XP, in case this is another Win9x bug.
> 
> As /dev doesn't exist on my computer, this wonn't work for me (and I suspect
> many Cygwin users).

Cygwin implements device files such as /dev/tty, /dev/null and
/dev/windows internally. Try "ls -l /dev/windows"; it works, even
though there isn't a /dev/directory.

> I found yesterday that I had to modify as follows to get the file to create
> the file, but still have a problem with events not being processed until a
> new display command is sent.  Prior to this I was getting a -1 return.
> 
> int
> XConnectionNumber(Display* display)
> {
>  int fd;
>  NT_debug ("XConnectionNumber\n");
>  fd = open ("/tmp/windows", O_CREAT | O_RDWR | O_NONBLOCK, 0);
>  if ( -1 == fd ) {
>    NT_log ("XConnectionNumber unable to open /tmp/windows, errno = %d\n",
> errno);
>  }
>  return ( fd );
> }
> 
> > Note: nothing should actually be read from /dev/windows. The
> > descriptor returned by XConnectionNumber() is passed to select(), in
> > get_connection_sock(), and in Get_Xevent(). Both of these functions
> > use select() to wait until either the monitor socket or the X
> > connection become readable.
> 
> Does this effectively mean that the fd is not used at all?

No, it means that nothing is read from the descriptor. It is still
used, in that the driver will attempt to process events when it is
readable (according to select()), and won't attempt to process events
if it isn't.

If you return a descriptor which is always readable (e.g. on Unix,
files are always readable; select() will return immediately if any of
the descriptors refer to a file), XDRIVER will busy-wait. While this
is less than ideal (it will consume CPU time and, on X, generate
traffic on the X connection), it may be a useful workaround.

-- 
Glynn Clements <glynn.clements at virgin.net>



More information about the grass-windows mailing list