This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: [PATCH] Fix PR gdb/18653: gdb disturbs inferior's inherited signal dispositions
- From: John Baldwin <jhb at freebsd dot org>
- To: gdb-patches at sourceware dot org
- Cc: Pedro Alves <palves at redhat dot com>
- Date: Thu, 04 Aug 2016 11:37:53 -0700
- Subject: Re: [PATCH] Fix PR gdb/18653: gdb disturbs inferior's inherited signal dispositions
- Authentication-results: sourceware.org; auth=none
- References: <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