> From: bastien ROUCARIES <roucaries.bast...@gmail.com>
> Date: Fri, 30 Dec 2011 12:36:07 +0100
> Cc: bonz...@gnu.org,
>  bug-gnulib@gnu.org,
>  bug-g...@gnu.org
> 
> > > In fact isatty under windows is equivalent to test if a file is a char
> > > device.
> > 
> > That is true.  But unless a Windows user goes out of their way, the
> > only character device they will ever see in routine operations is the
> > null device.
> Not true LPT is also a char device, and I use it for jtag stuff.

And the code I submitted says LPT is not a TTY.  In fact, it works
with every character device I tried: PRN, CLOCK$, and AUX.  So I see
no problem with the code I proposed.  Which character devices succeed
to dupe it?

> The right fix is :
> DWORD st;
> /* note use _ version for porting to vc */
> if(!_isattty(fd))
>       return 0;
> if (!GetConsoleMode(_get_osfhandle(fd), &st)) 
>       return 0;
> return 1;

Thanks.

> This is the idea, it is a little bit more complicated due to INVALID_HANDLE 
> exception raising in _get_osfhandle(fd) but the idea 
> is here. And moreover erno handling.

Further complications are the need to include windows.h, which could
interact in nasty ways with standard C headers or even macros such as
DATADIR.  So if the code I proposed doesn't break in practice, I think
its simplicity is a win.

Reply via email to