summaryrefslogtreecommitdiff
path: root/gnu/build/linux-container.scm
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2022-04-27 17:53:10 +0200
committerLudovic Courtès <ludo@gnu.org>2022-05-01 21:30:35 +0200
commitf6c9763984dafe5023e171878231cbcc6cc1edfa (patch)
tree7479794efd2326c38296e2d6b725583bdce045ab /gnu/build/linux-container.scm
parenta76fa226c8761dd349aaacca7ba041429bce4e73 (diff)
linux-container: Ensure signal-handling asyncs get a chance to run.
Previously we could enter the blocking 'waitpid' call and miss an opportunity to run the signal handler async. * gnu/build/linux-container.scm (call-with-container) [periodically-schedule-asyncs]: New procedure. [install-signal-handlers]: Call it.
Diffstat (limited to 'gnu/build/linux-container.scm')
-rw-r--r--gnu/build/linux-container.scm9
1 files changed, 9 insertions, 0 deletions
diff --git a/gnu/build/linux-container.scm b/gnu/build/linux-container.scm
index 03c01439cea..1fac8f4b92b 100644
--- a/gnu/build/linux-container.scm
+++ b/gnu/build/linux-container.scm
@@ -327,11 +327,20 @@ process when caught by its parent.
327Note that if THUNK needs to load any additional Guile modules, the relevant 327Note that if THUNK needs to load any additional Guile modules, the relevant
328module files must be present in one of the mappings in MOUNTS and the Guile 328module files must be present in one of the mappings in MOUNTS and the Guile
329load path must be adjusted as needed." 329load path must be adjusted as needed."
330 (define (periodically-schedule-asyncs)
331 ;; XXX: In Guile there's a time window where a signal-handling async could
332 ;; be queued without being processed by the time we enter a blocking
333 ;; syscall like waitpid(2) (info "(guile) Signals"). This terrible hack
334 ;; ensures pending asyncs get a chance to run periodically.
335 (sigaction SIGALRM (lambda _ (alarm 1)))
336 (alarm 1))
337
330 (define (install-signal-handlers pid) 338 (define (install-signal-handlers pid)
331 ;; Install handlers that forward signals to PID. 339 ;; Install handlers that forward signals to PID.
332 (define (relay-signal signal) 340 (define (relay-signal signal)
333 (false-if-exception (kill pid signal))) 341 (false-if-exception (kill pid signal)))
334 342
343 (periodically-schedule-asyncs)
335 (for-each (lambda (signal) 344 (for-each (lambda (signal)
336 (sigaction signal relay-signal)) 345 (sigaction signal relay-signal))
337 relayed-signals)) 346 relayed-signals))