This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: isatty gives wrong result via ssh


On Nov 26 10:08, Konstantin Kouptsov wrote:
> On Windows, if I compile it using a Microsoft compiler:
> 
> C: > cl /out:checktty.exe checktty.c
> 
> the program behaves correctly when I run it from a DOS prompt or from a Cywin's bash prompt. However, if I connect to the Windows computer running Cygwin's sshd service from another Linux or Windows computer, it always gives the same result:
> 
> $ ./checktty.exe
> not a tty
> 
> $ ./checktty.exe < checktty.c
> not a tty
> 
> (When I compile with Cygwin's gcc, everything is fine)
> 
> What happens here?

Cygwin pseudo ttys are implemented as pipes, and the msvcrt runtime
has no idea about that.  It sees a pipe and that's no tty from its
POV.

> Given that I must compile the program using Microsoft's compiler on Windows, how this can be worked around?

The workaround is to implement your own isatty function which recognizes
Cygwin pseudo ttys as well.  I had a customer asking this question, too,
at one point and I sent them example code.  I attached it to this mail.


HTH,
Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

Attachment: isatty-for-native-apps.c
Description: Text document

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]