From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25070 invoked by alias); 2 Dec 2005 21:06:25 -0000 Received: (qmail 25060 invoked by uid 22791); 2 Dec 2005 21:06:24 -0000 X-Spam-Status: No, hits=-2.5 required=5.0 tests=AWL,BAYES_00,FORGED_RCVD_HELO X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (66.187.233.31) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 02 Dec 2005 21:06:21 +0000 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11/8.12.11) with ESMTP id jB2L6JgD010528 for ; Fri, 2 Dec 2005 16:06:19 -0500 Received: from pobox.corp.redhat.com (pobox.corp.redhat.com [172.16.52.156]) by int-mx1.corp.redhat.com (8.11.6/8.11.6) with ESMTP id jB2L6JV06216 for ; Fri, 2 Dec 2005 16:06:19 -0500 Received: from localhost.localdomain (vpn50-83.rdu.redhat.com [172.16.50.83]) by pobox.corp.redhat.com (8.12.8/8.12.8) with ESMTP id jB2L6JT6020971 for ; Fri, 2 Dec 2005 16:06:19 -0500 Received: from ironwood.lan (ironwood.lan [192.168.64.8]) by localhost.localdomain (8.12.11/8.12.10) with ESMTP id jB2L6DB3014156 for ; Fri, 2 Dec 2005 14:06:13 -0700 Date: Fri, 02 Dec 2005 21:06:00 -0000 From: Kevin Buettner To: rda@sources.redhat.com Subject: [commit] Use SIGSTOP instead of SIGINT to interrupt inferior process Message-ID: <20051202140613.37ccf0db@ironwood.lan> Organization: Red Hat X-Mailer: Sylpheed-Claws 0.9.12cvs173.1 (GTK+ 2.4.14; i386-redhat-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-IsSubscribed: yes Mailing-List: contact rda-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: rda-owner@sourceware.org X-SW-Source: 2005-q4/txt/msg00009.txt.bz2 I've just committed that patch below. If the process has SIGINT blocked for some reason, there's no way to interrupt it from GDB. SIGSTOP can't be blocked, so it gives us a bulletproof way to interrupt the process. The one downside is that SIGSTOP is now the reason sent to GDB for stopping, By default, GDB is configured to pass SIGSTOP to the inferior, so the GDB user must use somewhat different commands in order to continue without causing the process to stop again with a SIGSTOP signal. This can be accomplished via the command "signal 0" which causes the inferior to continue with no signal or via "handle SIGSTOP nopass" which prevents SIGSTOP from being sent back to the inferior when continuing. * ptrace-target.c (ptrace_break_program): Use SIGSTOP instead of SIGINT to interrupt inferior process. * thread-db.c (thread_db_break_program): Likewise. Index: ptrace-target.c =================================================================== RCS file: /cvs/src/src/rda/unix/ptrace-target.c,v retrieving revision 1.10 diff -u -p -r1.10 ptrace-target.c --- ptrace-target.c 24 Aug 2005 01:14:35 -0000 1.10 +++ ptrace-target.c 2 Dec 2005 20:49:29 -0000 @@ -443,9 +443,11 @@ ptrace_break_program (struct gdbserv *se { struct child_process *process = gdbserv_target_data (serv); + /* We send SIGSTOP (rather than some other signal such as SIGINT) + because SIGSTOP cannot be blocked or ignored. */ if (process->debug_backend) - fprintf (stderr, " -- send SIGINT to child %d\n", process->pid); - kill (process->pid, SIGINT); + fprintf (stderr, " -- send SIGSTOP to child %d\n", process->pid); + kill (process->pid, SIGSTOP); } /* get_trap_number vector Index: thread-db.c =================================================================== RCS file: /cvs/src/src/rda/unix/thread-db.c,v retrieving revision 1.17 diff -u -p -r1.17 thread-db.c --- thread-db.c 2 Dec 2005 00:49:14 -0000 1.17 +++ thread-db.c 2 Dec 2005 20:49:29 -0000 @@ -2073,10 +2073,15 @@ thread_db_break_program (struct gdbserv /* We always send the signal to the main thread. It's not correct to use process->pid; that's whatever thread last reported a - status, and it may well have been exiting. */ + status, and it may well have been exiting. + + We send SIGSTOP, rather than some other signal such as SIGINT, + because SIGSTOP cannot be blocked or ignored. On Linux, using + a signal that can be blocked means that the process never gets + interrupted, since it's the kernel which does the blocking. */ if (process->debug_backend) - fprintf (stderr, " -- send SIGINT to child %d\n", proc_handle.pid); - kill (proc_handle.pid, SIGINT); + fprintf (stderr, " -- send SIGSTOP to child %d\n", proc_handle.pid); + kill (proc_handle.pid, SIGSTOP); } /* Function: check_child_state