]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commit
Don't call sigtimedwait for scoped_ignore_sigttou
authorPedro Alves <pedro@palves.net>
Thu, 17 Jun 2021 15:23:03 +0000 (16:23 +0100)
committerPedro Alves <pedro@palves.net>
Thu, 17 Jun 2021 18:39:08 +0000 (19:39 +0100)
commit336b30e58ae98fe66862ab8480d3f7bb885fef23
treeb0def784a1fefc869831e11a4ec3b29edea55501
parente013d20dc73b40d4b70c4a366c9adc619503e66b
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  <pedro@palves.net>

* 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)
<m_ignore_signal>: Initialize with ConsumePending=false.

Change-Id: I92f754dbc45c45819dce2ce68b8c067d8d5c61b1
gdb/ChangeLog
gdbsupport/scoped_ignore_signal.h
gdbsupport/scoped_ignore_sigttou.h