This is the mail archive of the cygwin@cygwin.com 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]

RE: RE: Cannot change console mode when set CYGWIN=tty


I wish life was so simple.  If I was only developing in cygwin/Unix, I 
would have trashed all of the MS stuff long ago....
I agree with your solutions and appreciate your recommendations.  However, 
I need to be able to compile this code using "native" tools so that I can 
deliver the source to my other users that have never had the fortune to 
work with cygwin (and Unix) and only have MSVC...  I only run the tests in 
cygwin/bash because it is so much better/convenient than cmd.exe.  I guess 
for testing this stuff, I will have to create an instance that doesn't set 
CYGWIN=tty.  (Or find a way to break the pipe and reopen the STDIN handle 
in windows, although I doubt this will work ...)

Thanks,
  - Mike

At 07:47 AM 7/27/2001 -0600, you wrote:
>I would also consider leaving your old code intact and
>using isatty() to toggle between the older console
>code and the new technique that Egor suggests.
>
>Such as:
>
>if (isatty()) {
>    /* use tty-style handling here */
>} else {
>    /* your old console-style code here */
>}
>
>That way if a user does not set CYGWIN=tty
>your code will continue to work in either case.
>
>Troy
>
>-----Original Message-----
>From: egor duda [mailto:deo@logos-m.ru]
>Sent: Friday, July 27, 2001 7:37 AM
>To: Mike Gingell
>Cc: cygwin@cygwin.com
>Subject: Re: Cannot change console mode when set CYGWIN=tty
>
>
>Hi!
>
>Friday, 27 July, 2001 Mike Gingell mgingell@accesswave.ca wrote:
>
>MG> In order to fix a minor problem caused by ^C being intercepted by bash,
>I
>MG> set CYGWIN=tty before launching bash.  This solves the problem of cmd
>MG> asking the user to terminate the batch job.  This is great, however, it
>MG> breaks some of my other existing code, specifically the ability to
>change
>MG> the Console mode.  i.e.  with CYGWIN=tty:
>
>MG>    Error getting console mode (Error 6): The handle is invalid.
>MG>    exception....GetConsoleMode
>MG>    [436]:[darkfriend:/d/rfr/mtQACE]:
>
>MG> without CYGWIN=tty, all works fine.....
>
>MG> This is the code that I use:
>MG>      // Turn off the line input mode, and echo the input mode.
>MG>      if (! GetConsoleMode(hStdin, &fdwOldMode)) {
>MG>          printErr("Error getting console mode", GetLastError());
>MG>          throw runtime_error("GetConsoleMode");
>MG>          }
>MG>      fdwMode = fdwOldMode & ~(ENABLE_LINE_INPUT
>MG>                             | ENABLE_ECHO_INPUT
>MG>                             | ENABLE_PROCESSED_INPUT );
>MG>      if (! SetConsoleMode(hStdin, fdwMode)) {
>MG>          printErr("Error setting console mode", GetLastError());
>MG>          throw runtime_error("SetConsoleMode");
>MG>          }
>
>MG> Is there a work around for this?  If not, I will have to run without
>MG> CYGWIN=tty until I get a chance to dig into the source and find out what
>
>MG> CYGWIN=tty really does.
>MG> Cheers!
>
>it enables emulation of unix-like ttys. so, when your program runs in
>such "tty" environment, its hStdin is a pipe to tty master. use unix
>api to control tty mode instead of windows. see tcsetattr() function
>for details.
>
>Egor.            mailto:deo@logos-m.ru ICQ 5165414 FidoNet 2:5020/496.19
>
>
>--
>Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
>Bug reporting:         http://cygwin.com/bugs.html
>Documentation:         http://cygwin.com/docs.html
>FAQ:                   http://cygwin.com/faq/

Mike Gingell, P.Eng.
Senior Systems Engineer, Maritime Systems
Computing Devices Canada


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


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