From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 17396 invoked by alias); 11 May 2008 16:41:08 -0000 Received: (qmail 17385 invoked by uid 22791); 11 May 2008 16:41:07 -0000 X-Spam-Check-By: sourceware.org Received: from rock.gnat.com (HELO rock.gnat.com) (205.232.38.15) by sourceware.org (qpsmtpd/0.31) with ESMTP; Sun, 11 May 2008 16:40:47 +0000 Received: from localhost (localhost.localdomain [127.0.0.1]) by filtered-rock.gnat.com (Postfix) with ESMTP id 87C212A98B1 for ; Sun, 11 May 2008 12:40:45 -0400 (EDT) Received: from rock.gnat.com ([127.0.0.1]) by localhost (rock.gnat.com [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 1ny2DbSPLK66 for ; Sun, 11 May 2008 12:40:45 -0400 (EDT) Received: from joel.gnat.com (localhost.localdomain [127.0.0.1]) by rock.gnat.com (Postfix) with ESMTP id 30BB32A98AA for ; Sun, 11 May 2008 12:40:45 -0400 (EDT) Received: by joel.gnat.com (Postfix, from userid 1000) id 1E486E7ACD; Sun, 11 May 2008 09:40:43 -0700 (PDT) Date: Sun, 11 May 2008 21:26:00 -0000 From: Joel Brobecker To: gdb-patches@sourceware.org Subject: Re: [RFC] control-c handling on Windows... Message-ID: <20080511164043.GJ28890@adacore.com> References: <20080507205611.GB7421@adacore.com> <20080509202942.GA4386@ednor.casa.cgf.cx> <20080510013336.GC28890@adacore.com> <20080510043413.GA5429@ednor.casa.cgf.cx> <20080510153102.GE28890@adacore.com> <20080510180010.GF28890@adacore.com> <20080510194232.GC17229@ednor.casa.cgf.cx> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20080510194232.GC17229@ednor.casa.cgf.cx> User-Agent: Mutt/1.4.2.2i Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2008-05/txt/msg00361.txt.bz2 > >I wonder if there might be some sort of timing issue that causes > >the signal to sometimes be delivered after we stopped ignoring control > >events. In other words, some of the time, we receive the signal > >reasonably close to when we receive the debug event for the new thread, > >and so it gets ignored. But some other time, we receive the signal > >sufficiently after we got the debug event that we already got out of > >get_win32_debug_event and restored the regular SIGINT handler... > >That would explain why we're seeing the QUIT message. > > i.e., it's a classic race. Yes, and I'm still not sure how to solve it completely :-(. I double-checked the cygwin case inside a cygwin window, and things seem to be pretty solid as soon as the SetConsoleCtrlHandler wrapper is installed. Not sure whether it's a coincidence or whether it's expected that I wouldn't see that race with a cygwin window (and in fact, I'm not sure that the cygwin window is relevant to the experiment either). I did verify it again in the case of mingw. So, I suggest we install you patch for now. Hopefully we'll find a way to get rid of the race condition, but in the meantime, we have something that makes the situation better. > >On a side note, utils.c:quit is: > > > > void > > quit (void) > > { > > #ifdef __MSDOS__ > > /* No steenking SIGINT will ever be coming our way when the > > program is resumed. Don't lie. */ > > fatal ("Quit"); > > #else > > if (job_control > > /* If there is no terminal switching for this target, then we can't > > possibly get screwed by the lack of job control. */ > > || current_target.to_terminal_ours == NULL) > > fatal ("Quit"); > > else > > fatal ("Quit (expect signal SIGINT when the program is resumed)"); > > #endif > > } > > > >Not sure when __MSDOS__ is defined, but perhaps we should extend > >that case to mingw & cygwin as well? At least we wouldn't get the > >"expect signal SIGINT when the program is resumed" part which > >I don't think can happen on Windows anymore. > > I'm still assuming that you're talking about mingw here since Cygwin should > have different behavior. For instance, it implements tcsetpgrp. Ah, you're right, that would cause job_control to be set on cygwin, I think. So that means we would probably want to emulate the __MSDOS__ case for mingw only. -- Joel