From 8576be0f3506711bb587e6f726d332415131a6ef Mon Sep 17 00:00:00 2001 From: Julian Squires Date: Sat, 25 Nov 2023 15:09:06 -0330 Subject: [PATCH] Restore echo-signal sigaction for OpenBSD I was excited about having less junk here but unfortunately OpenBSD seems to treat (at least) SIGTSTP and SIGCONT as if they were SIG_IGN, which means they'll be discarded instead of marked pending, so we need to install a signal handler anyway. --- helpers/echo-signal.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/helpers/echo-signal.c b/helpers/echo-signal.c index 6b30466..58d6438 100755 --- a/helpers/echo-signal.c +++ b/helpers/echo-signal.c @@ -21,17 +21,24 @@ static int int_of_signal_name(char *name) abort(); } + +static sig_atomic_t got; +static void handler(int n) { got = n; } + int main(int argc, char **argv) { if (2 != argc) abort(); int sig = int_of_signal_name(argv[1]); + // This handler _should_ be unnecessary for these signals and + // sigwait, except that OpenBSD seems to consider TSTP and CONT as + // being ignored by default (though POSIX says otherwise). + sigaction(sig, &(struct sigaction){.sa_handler=handler}, NULL); sigset_t set, prev; sigemptyset(&set); sigaddset(&set, sig); sigprocmask(SIG_BLOCK, &set, &prev); write(1, "ready\n", 6); - int got; do { sigwait(&set, &got); } while (sig != got); puts(argv[1]); return 0;