diff --git a/modules.scm b/modules.scm index 0efc335..2f2d247 100644 --- a/modules.scm +++ b/modules.scm @@ -12,12 +12,14 @@ (files format-net)) (define-interface sunet-utilities-interface - (export host-name-or-ip)) + (export host-name-or-ip + on-interrupt)) (define-structure sunet-utilities sunet-utilities-interface (open scsh scheme format-net + sigevents handle-fatal-error) (files sunet-utilities)) diff --git a/sunet-utilities.scm b/sunet-utilities.scm index ee2a1cd..734a222 100644 --- a/sunet-utilities.scm +++ b/sunet-utilities.scm @@ -9,3 +9,8 @@ (format-internet-host-address ip)))) (host-info:name (host-info addr)))) +(define (on-interrupt interrupt thunk) + (let lp ((event (most-recent-sigevent))) + (let ((next (next-sigevent event interrupt))) + (thunk) + (lp next))))