Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT sources DOT redhat DOT com Delivered-To: mailing list cygwin AT sources DOT redhat DOT com Message-Id: <5.1.0.14.0.20010727130257.00a8bfe0@mail.accesswave.ca> X-Sender: mgingell AT mail DOT accesswave DOT ca X-Mailer: QUALCOMM Windows Eudora Version 5.1 Date: Fri, 27 Jul 2001 13:32:07 -0300 To: "cygwin-cygwin.com" From: Mike Gingell Subject: RE: RE: Cannot change console mode when set CYGWIN=tty In-Reply-To: <8F23E55D511AD5119A6800D0B76FDDE1CA2F84@cpex3.channelpoint. com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed 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 AT logos-m DOT ru] >Sent: Friday, July 27, 2001 7:37 AM >To: Mike Gingell >Cc: cygwin AT cygwin DOT com >Subject: Re: Cannot change console mode when set CYGWIN=tty > > >Hi! > >Friday, 27 July, 2001 Mike Gingell mgingell AT accesswave DOT 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 AT logos-m DOT 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/