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: <000d01c0d022$c577c480$248a42d8@hpcustomer> From: "Tim Baker" To: Subject: cygwin apps in pipe ignore ctrl+c FIX Date: Sat, 28 Apr 2001 13:32:54 -0700 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4522.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200 In a previous message I reported that Cygwin apps running in a pipe would ignore Ctrl+C from the command-line. So I got the sources and built cygwin1.dll, and found the problem in winsup/cygwin/exceptions.cc. This is the original code (relevant parts only): static BOOL WINAPI ctrl_c_handler (DWORD type) { tty_min *t = cygwin_shared->tty.get_tty (myself->ctty); if (t->getpgid () != myself->pid || (GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP) return TRUE; else { t->last_ctrl_c = GetTickCount (); kill (-myself->pid, SIGINT); t->last_ctrl_c = GetTickCount (); return TRUE; } } The problem was that t->getpgid() returns *zero*. So I added a check for zero as follows: static BOOL WINAPI ctrl_c_handler (DWORD type) { if (t->getpgid () && ((t->getpgid () != myself->pid) || ((GetTickCount () - t->last_ctrl_c) < MIN_CTRL_C_SLOP))) return TRUE; else { t->last_ctrl_c = GetTickCount (); kill (-myself->pid, SIGINT); t->last_ctrl_c = GetTickCount (); return TRUE; } } Now Ctrl+C and GenerateConsoleCtrlEvent() work great for apps in a pipe. -- Tim Baker -- Want to unsubscribe from this list? Check out: http://cygwin.com/ml/#unsubscribe-simple