Le Wednesday 28 December 2011 18:12:06, Eli Zaretskii a écrit : > > Date: Wed, 28 Dec 2011 17:06:05 +0100 > > From: Bastien ROUCARIES <roucaries.bast...@gmail.com> > > Cc: Eli Zaretskii <e...@gnu.org>, bug-gnulib <bug-gnulib@gnu.org>, > > bug-g...@gnu.org > > > > Isatty is broken under windows but this not the right fix. > > What's wrong about it? If it fails under some conditions, please > describe them. > > > 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.
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; 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. With this code is it is guaranted that only CON will be considered as interactive. if you want to test modem and COM port you should use GetCommProperties and dwProvSubType member of COMMPROP structure. Sorry for first top post from my mobile phone Thanks Bastien