From 6f402d4a5281f3a0f993581ee086a4b76539318e Mon Sep 17 00:00:00 2001 From: Jack Conger Date: Tue, 29 Jul 2025 14:54:06 -0700 Subject: [PATCH 1/2] Small changes for signal delivery in exception catchers. There's a SIGCHK() that could make life a little easier, and a test to make sure we block (and unblock) signal delivery correctly. --- prim-ctl.c | 1 + test/tests/trip.es | 29 +++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) diff --git a/prim-ctl.c b/prim-ctl.c index 19cb1dd6..f8a09020 100644 --- a/prim-ctl.c +++ b/prim-ctl.c @@ -85,6 +85,7 @@ PRIM(catch) { EndExceptionHandler } while (retry); RefEnd(lp); + SIGCHK(); RefReturn(result); } diff --git a/test/tests/trip.es b/test/tests/trip.es index 69dc4736..26c4401e 100644 --- a/test/tests/trip.es +++ b/test/tests/trip.es @@ -159,6 +159,35 @@ never succeeded } } +test 'signals in exception catchers' { + local (signals = sigint) { + let ( + was-blocked = false + thrown = () + thrown2 = () + ) { + catch @ { + thrown = $* + } { + catch @ e { + kill -INT $pid + was-blocked = true + } { + throw exception + } + } + catch @ { + thrown2 = $* + } { + catch @ e {kill -INT $pid} {throw exception2} + } + assert $was-blocked signal is blocked during catcher + assert {~ $thrown(1) signal} signal exception during catcher is thrown + assert {~ $thrown2(1) signal} second signal is caught + } + } +} + test 'heredocs and herestrings' { let (bigfile = `{mktemp big-file.XXXXXX}) unwind-protect { From 220fc28ef2a3ea79606dc5f283ceeab9bd2944fe Mon Sep 17 00:00:00 2001 From: Jack Conger Date: Wed, 30 Jul 2025 21:48:30 -0700 Subject: [PATCH 2/2] SIGCHK() inside of exception-handling loop --- prim-ctl.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/prim-ctl.c b/prim-ctl.c index f8a09020..d8d4e31c 100644 --- a/prim-ctl.c +++ b/prim-ctl.c @@ -83,9 +83,10 @@ PRIM(catch) { EndExceptionHandler EndExceptionHandler + + SIGCHK(); } while (retry); RefEnd(lp); - SIGCHK(); RefReturn(result); }