Skip to content

Instantly share code, notes, and snippets.

@zarkone
Created February 14, 2018 05:41
Show Gist options
  • Save zarkone/fbe223675113d7e545c3d1483b4a66ff to your computer and use it in GitHub Desktop.
Save zarkone/fbe223675113d7e545c3d1483b4a66ff to your computer and use it in GitHub Desktop.
Intercept POSIX signals (like, from kill -SIGHUP) in Clojure
(ns signals-handler
(:import [sun.misc Signal SignalHandler]))
(defn handle-signals
"Sets up POSIX signal handlers."
[]
(Signal/handle
(Signal. "HUP")
(proxy [SignalHandler] []
(handle [sig]
(println "Caught SIGHUP, reloading")
;; reload-config or whatever you want
(reload-config!)))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment