From cb03e36088f66e79b6f69c26aee7353d10031d13 Mon Sep 17 00:00:00 2001 From: Yogthos Date: Wed, 1 Jul 2026 14:23:19 -0400 Subject: [PATCH] Don't abort startup on Windows resolving POSIX signal fns MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit joltc failed to start on Windows — "Exception in foreign-procedure: no entry for pthread_sigmask". concurrency.ss resolves pthread_sigmask/sigemptyset/sigaddset at load with a top-level (foreign-procedure …), which resolves its symbol eagerly; those POSIX signal fns don't exist on Windows, so the whole runtime aborted. Guard the three resolutions (like sched_yield/chmod already are) so a non-POSIX host yields #f, and make jolt-set-sigint-blocked a no-op when they're unavailable. The per-thread SIGINT mask is a POSIX-only optimization for the nREPL accept loop; Windows delivers ^C through the console, and park-until-interrupt still parks on a condition variable. macOS/Linux resolve the symbols as before — unchanged. --- host/chez/java/concurrency.ss | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/host/chez/java/concurrency.ss b/host/chez/java/concurrency.ss index 3469e07..6d96677 100644 --- a/host/chez/java/concurrency.ss +++ b/host/chez/java/concurrency.ss @@ -547,10 +547,14 @@ ;; sigaddset are libc/libpthread symbols, resolvable once the process object is ;; loaded (as the socket fns already are). 128 bytes covers Linux's 1024-bit ;; sigset_t and is larger than macOS's 4-byte one. +;; foreign-procedure resolves its symbol eagerly, and these POSIX signal fns don't +;; exist on Windows — resolving them unguarded aborted startup ("no entry for +;; pthread_sigmask"). Guard so a non-POSIX host yields #f; jolt-set-sigint-blocked +;; then no-ops (Windows delivers ^C through the console, not a per-thread mask). (define c-pthread-sigmask - (foreign-procedure "pthread_sigmask" (int u8* u8*) int)) -(define c-sigemptyset (foreign-procedure "sigemptyset" (u8*) int)) -(define c-sigaddset (foreign-procedure "sigaddset" (u8* int) int)) + (guard (e (#t #f)) (foreign-procedure "pthread_sigmask" (int u8* u8*) int))) +(define c-sigemptyset (guard (e (#t #f)) (foreign-procedure "sigemptyset" (u8*) int))) +(define c-sigaddset (guard (e (#t #f)) (foreign-procedure "sigaddset" (u8* int) int))) ;; POSIX SIG_BLOCK/SIG_UNBLOCK numerics differ by platform: Linux/glibc 0/1, ;; Darwin/macOS 1/2 (SIG_UNBLOCK is SIG_BLOCK+1 on both). Resolve SIG_BLOCK for ;; this host from the machine-type symbol — macOS builds contain "osx". @@ -563,12 +567,13 @@ ((string=? (substring s i (+ i 3)) "osx") 1) ; Darwin/macOS (else (loop (+ i 1))))))) (define (jolt-set-sigint-blocked block?) - (let ((set (make-bytevector 128 0)) - (old (make-bytevector 128 0))) - (c-sigemptyset set) - (c-sigaddset set 2) ; SIGINT = 2 - (c-pthread-sigmask (if block? jolt-sig-block-how (+ jolt-sig-block-how 1)) set old) - jolt-nil)) + (when (and c-pthread-sigmask c-sigemptyset c-sigaddset) + (let ((set (make-bytevector 128 0)) + (old (make-bytevector 128 0))) + (c-sigemptyset set) + (c-sigaddset set 2) ; SIGINT = 2 + (c-pthread-sigmask (if block? jolt-sig-block-how (+ jolt-sig-block-how 1)) set old))) + jolt-nil) (def-var! "jolt.host" "call-on-main-thread" jolt-call-on-main-thread) (def-var! "jolt.host" "run-main-pump" jolt-run-main-pump)