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: <8F23E55D511AD5119A6800D0B76FDDE11E1008@cpex3.channelpoint.com> From: Troy Noble To: "'cygwin AT cygwin DOT com'" Subject: Brainstorming a fix for CTRL-C handling in an emacs shell buffer (non-TTY) Date: Fri, 4 May 2001 12:40:33 -0600 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2653.19) Content-Type: text/plain; charset="iso-8859-1" X-Scanned-By: MIMEDefang 1.0 (http://www.roaringpenguin.com/mimedefang/) I have been reading through the list archives and the latest CVS 1.3.2 code a bit today, so am pretty confident I understand most of the issues related to CTRL-C not generating SIGINT when stdin is not a tty (like inside a Win32 NTEmacs shell buffer). Here's an earlier discussion on this same subject: http://cygwin.com/ml/cygwin/2001-01/msg00578.html and ff. Would it be possible to add a new "CYGWIN=" option or environment variable to allow one to turn on CTRL-C handling even if stdin is not a tty? .../cygwin$ diff -b --unified=3 exceptions.cc-orig exceptions.cc diff -b --unified=3 exceptions.cc-orig exceptions.cc --- exceptions.cc-orig Sun Apr 29 21:09:18 2001 +++ exceptions.cc Fri May 4 12:10:44 2001 @@ -878,6 +878,7 @@ static BOOL WINAPI ctrl_c_handler (DWORD type) { + static CHAR envBuf[MAX_PATH]; if (type == CTRL_LOGOFF_EVENT) return TRUE; @@ -892,8 +893,10 @@ tty_min *t = cygwin_shared->tty.get_tty (myself->ctty); /* Ignore this if we're not the process group lead since it should be handled *by* the process group leader. */ - if (!t->getpgid () || t->getpgid () != myself->pid || - (GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP) + if (GetEnvironmentVariable("CYGWIN_HANDLE_NONTTY_CTRL_C", + envBuf, MAX_PATH-1)==0 && + (!t->getpgid () || t->getpgid () != myself->pid || + (GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP)) return TRUE; else /* Otherwise we just send a SIGINT to the process group and return TRUE (to indicate I tried the above hack of the latest sources just to test my theory. I don't claim it's the best way to do it, or even that it's "good" code. I don't know enough about internals of CYGWIN to advocate one way or another whether it should be a CYGWIN= or an environment variable. But it would really be nice to have if you can come up with a cleaner way to do it. The only obvious side-effect I've observed thusfar is: bash: [792: 1] tcsetattr: Not a character device when I use CTRL-C inside emacs. But the subprocess does get a SIGINT as I'd like. Outside of emacs, everything works as it always has. For non-cygwin apps running inside of emacs, I was still able to kill the processes as well (Note that I discovered a while back that I also had to NOT put "tty" in my CYGWIN= variable to allow me to kill non-cygwin processes... but that's possibly another issue altogether). P.S. I did also read the discussion about switching to XEmacs built for cygwin, but would like to get it to work with native NTEmacs as well... since that's what we use here. BTW, this same CTRL-C behavior did work in B20.1. There was some doubt about that in the prior e-mail thread. -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple