From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7605 invoked by alias); 18 May 2006 22:52:50 -0000 Received: (qmail 7595 invoked by uid 22791); 18 May 2006 22:52:49 -0000 X-Spam-Check-By: sourceware.org Received: from intranet.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.6) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 18 May 2006 22:52:47 +0000 Received: (qmail 1822 invoked from network); 18 May 2006 22:52:45 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 18 May 2006 22:52:45 -0000 To: Andreas Schwab Cc: Alain Magloire , gdb@sources.redhat.com Subject: Re: invoking GDB from FE and signals References: <3518719F06577C4F85DA618E3C37AB91054A9EFD@nimbus.ott.qnx.com> <20060518172253.GE21003@brasko.net> From: Jim Blandy Date: Thu, 18 May 2006 23:28:00 -0000 In-Reply-To: (Andreas Schwab's message of "Thu, 18 May 2006 23:49:01 +0200") Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2006-05/txt/msg00289.txt.bz2 Andreas Schwab writes: > Bob Rossi writes: > >> I find in emacs:process.c code that they send the SIGINT in different >> ways >> /* If possible, send signals to the entire pgrp >> by sending an input character to it. */ >> >> /* TERMIOS is the latest and bestest, and seems most likely to >> work. If the system has it, use it. */ >> case SIGINT: >> sig_char = &t.c_cc[VINTR]; >> break; >> ... >> send_process (proc, sig_char, 1, Qnil); > > This part is only active if SIGNALS_VIA_CHARACTERS is defined. That is > defined mostly for BSD-derived systems, but not, for example, for Linux. > The fallback is to send the signal to the foreground process group of the > terminal. Do you know why they prefer that approach on Linux? There are race conditions doing it either way, but the SIGNALS_VIA_CHARACTERS one seems less likely: - If SIGNALS_VIA_CHARACTERS is #defined, then we get the tty's "intr" character and send that. The race is that the child could change its "intr" character between the time we fetch it and the time the tty processes the one we've sent. - Otherwise, we get the tty's controlling process group with tcgetpgrp, and then use killpg to send that process group the signal we want. The race is that the child could change its process group between the time we fetch it and the time we send it. A shell changes the terminal's process group every time it runs a command.