public inbox for rda@sourceware.org
 help / color / mirror / Atom feed
From: Kevin Buettner <kevinb@redhat.com>
To: rda@sources.redhat.com
Subject: [commit] Use SIGSTOP instead of SIGINT to interrupt inferior  process
Date: Fri, 02 Dec 2005 21:06:00 -0000	[thread overview]
Message-ID: <20051202140613.37ccf0db@ironwood.lan> (raw)

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

                 reply	other threads:[~2005-12-02 21:06 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20051202140613.37ccf0db@ironwood.lan \
    --to=kevinb@redhat.com \
    --cc=rda@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).