Skip to content

Commit 86535bb

Browse files
committed
Add ANY_TRIGGERED shortcut
1 parent 6faf263 commit 86535bb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

vm/src/stdlib/signal.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,10 @@ const SIG_ERR: libc::sighandler_t = !0;
2626
// We cannot use the NSIG const in the arr macro. This will fail compilation if NSIG is different.
2727
static TRIGGERS: [AtomicBool; NSIG] = arr![AtomicBool::new(false); 64];
2828

29+
static ANY_TRIGGERED: AtomicBool = AtomicBool::new(false);
30+
2931
extern "C" fn run_signal(signum: i32) {
32+
ANY_TRIGGERED.store(true, Ordering::Relaxed);
3033
TRIGGERS[signum as usize].store(true, Ordering::Relaxed);
3134
}
3235

@@ -93,6 +96,9 @@ fn alarm(time: PyIntRef, _vm: &VirtualMachine) -> u32 {
9396
}
9497

9598
pub fn check_signals(vm: &VirtualMachine) -> PyResult<()> {
99+
if !ANY_TRIGGERED.swap(false, Ordering::Relaxed) {
100+
return Ok(());
101+
}
96102
for (signum, trigger) in TRIGGERS.iter().enumerate().skip(1) {
97103
let triggerd = trigger.swap(false, Ordering::Relaxed);
98104
if triggerd {

0 commit comments

Comments
 (0)