From 4dba818c8345288c10fca92062446b8a3c34ee06 Mon Sep 17 00:00:00 2001 From: 4lDO2 <4lDO2@protonmail.com> Date: Sun, 30 Jun 2024 16:39:18 +0200 Subject: [PATCH] Check pending unblocked signals before blocking. This is not a perfect solution, since the kernel technically already has all the information it needs to synchronize this between the kill() invocation and the time WaitCondition::wait is called, but it should not have any noticeable performance impact. --- src/sync/wait_condition.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sync/wait_condition.rs b/src/sync/wait_condition.rs index b6fb71b00e..bbb47fc3ed 100644 --- a/src/sync/wait_condition.rs +++ b/src/sync/wait_condition.rs @@ -48,6 +48,9 @@ impl WaitCondition { { let mut context = context_lock.write(); + if let Some((control, _, _)) = context.sigcontrol() && control.currently_pending_unblocked() != 0 { + return false; + } id = context.id; context.block(reason); }