public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: John Baldwin <jhb@freebsd.org>
To: gdb-patches@sourceware.org
Cc: Pedro Alves <palves@redhat.com>
Subject: Re: [PATCH] Fix PR gdb/18653: gdb disturbs inferior's inherited signal dispositions
Date: Fri, 05 Aug 2016 00:08:00 -0000	[thread overview]
Message-ID: <2148041.k6fglmTO5R@ralph.baldwin.cx> (raw)
In-Reply-To: <1470332251-10857-1-git-send-email-palves@redhat.com>

On Thursday, August 04, 2016 06:37:31 PM Pedro Alves wrote:
> Today I was helping Phil debug something on the new C++ compile
> support, and we noticed that when debugging gdb under gdb, the
> inferior gdb behaved differently compared to when it was not being
> debugged.  Turned out to be a manifestation of PR gdb/18653.
> 
> Since the exec family of functions do not reset the signal disposition
> of signals that are set to SIG_IGN:
> 
>   http://pubs.opengroup.org/onlinepubs/7908799/xsh/execve.html
> 
>   Signals set to the default action (SIG_DFL) in the calling process
>   image are set to the default action in the new process
>   image. Signals set to be ignored (SIG_IGN) by the calling process
>   image are set to be ignored by the new process image. Signals set to
>   be caught by the calling process image are set to the default action
>   in the new process image (see <signal.h>).
> 
> gdb's (or gdbserver's) own signal handling should not interfere with
> the signal dispositions their spawned children inherit.  However, it
> currently does.  For example, some paths in gdb cause SIGPIPE to be
> set to SIG_IGN, and as consequence, the child starts with SIGPIPE to
> set to SIG_IGN too, even though gdb was started with SIGPIPE set to
> SIG_DFL.
> 
> In order to be transparent, when spawning new child processes to debug
> (with "run", etc.), reset all signal dispositions back to what was
> originally inherited from gdb/gdbserver's parent, just before execing
> the target program to debug.

Perhaps consider saving/restore the entire 'struct sigaction' instead
of just the sa_handler field given you are already requiring
sigaction?

-- 
John Baldwin

  reply	other threads:[~2016-08-05  0:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-04 17:37 Pedro Alves
2016-08-05  0:08 ` John Baldwin [this message]
2016-08-05  1:04   ` Pedro Alves
2016-08-05 10:57     ` [PATCH v2] " Pedro Alves
2016-08-08 17:28       ` John Baldwin
2016-08-12  8:21       ` Yao Qi
2016-08-12  9:08         ` Pedro Alves
2016-08-22 14:28       ` Yao Qi
2016-08-22 14:34         ` Pedro Alves
2016-08-23 13:20           ` Yao Qi

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=2148041.k6fglmTO5R@ralph.baldwin.cx \
    --to=jhb@freebsd.org \
    --cc=gdb-patches@sourceware.org \
    --cc=palves@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).