This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Fix PR gdb/18653: gdb disturbs inferior's inherited signal dispositions


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]