delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2001/04/28/17:04:42

Mailing-List: contact cygwin-help AT sourceware DOT cygnus DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT sources DOT redhat DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT sources DOT redhat DOT com>
List-Help: <mailto:cygwin-help AT sources DOT redhat DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT sources DOT redhat DOT com
Delivered-To: mailing list cygwin AT sources DOT redhat DOT com
Date: Sat, 28 Apr 2001 17:05:01 -0400
From: Christopher Faylor <cgf AT redhat DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: cygwin apps in pipe ignore ctrl+c FIX
Message-ID: <20010428170501.C7632@redhat.com>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <000d01c0d022$c577c480$248a42d8 AT hpcustomer>
Mime-Version: 1.0
User-Agent: Mutt/1.3.11i
In-Reply-To: <000d01c0d022$c577c480$248a42d8@hpcustomer>; from dbaker@direct.ca on Sat, Apr 28, 2001 at 01:32:54PM -0700

On Sat, Apr 28, 2001 at 01:32:54PM -0700, Tim Baker wrote:
>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:

Thank you for looking into this, but just as a hint, when debugging
this type of thing, it is usually better to figure out if the code
to not account for whether the value was zero or if it is, in fact,
a bug that the value can be zero.

I don't know if pgid is supposed to be nonzero in this case, but
I suspect that it is.

cgf

>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.

--
Want to unsubscribe from this list?
Check out: http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019