From 336b30e58ae98fe66862ab8480d3f7bb885fef23 Mon Sep 17 00:00:00 2001 From: Pedro Alves Date: Thu, 17 Jun 2021 16:23:03 +0100 Subject: Don't call sigtimedwait for scoped_ignore_sigttou Because SIGTTOU is sent to the whole process instead of to a specific thread, consuming a pending SIGTTOU in the destructor of scoped_ignore_sigttou could consume a SIGTTOU signal raised due to actions done by some other thread. Simply avoid sigtimedwait in scoped_ignore_sigttou, thus plugging the race. This works because we know that when the thread writes to the terminal and the signal is blocked, the kernel does not raise the signal at all. Tested on GNU/Linux, Solaris 11 and FreeBSD. gdb/ChangeLog: yyyy-mm-dd Pedro Alves * scoped_ignore_signal.h (scoped_ignore_signal): Add ConsumePending template parameter. (scoped_ignore_signal::~scoped_ignore_signal): Skip calling sigtimedwait if ConsumePending is false. (scoped_ignore_sigpipe): Initialize with ConsumePending=true. * scoped_ignore_sigttou.h (scoped_ignore_sigttou) : Initialize with ConsumePending=false. Change-Id: I92f754dbc45c45819dce2ce68b8c067d8d5c61b1 --- gdb/ChangeLog | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'gdb') diff --git a/gdb/ChangeLog b/gdb/ChangeLog index e4e5817..c70f6ef 100644 --- a/gdb/ChangeLog +++ b/gdb/ChangeLog @@ -1,5 +1,15 @@ 2021-06-17 Pedro Alves + * scoped_ignore_signal.h (scoped_ignore_signal): Add + ConsumePending template parameter. + (scoped_ignore_signal::~scoped_ignore_signal): Skip calling + sigtimedwait if ConsumePending is false. + (scoped_ignore_sigpipe): Initialize with ConsumePending=true. + * scoped_ignore_sigttou.h (scoped_ignore_sigttou) + : Initialize with ConsumePending=false. + +2021-06-17 Pedro Alves + * Makefile.in (SELFTESTS_SRCS): Add unittests/scoped_ignore_signal-selftests.c. * unittests/scoped_ignore_signal-selftests.c: New. -- cgit v1.1