os/signal.Notify relays selected signals to a Go channel. os.Signal is the channel's element type, and os.Interrupt is Ctrl-C. Receive with go/recv and the program keeps running after the signal.
os/signal.Notify
os.Signal
os.Interrupt
go/recv
(def ch (go/make (go/chan-of os.Signal) 1)) (os:signal.Notify ch os.Interrupt) (println "waiting") (let [[sig ok] (go/recv ch)] (println "got" (str sig) ok))
Run the program, then send it an interrupt.
$ glj signals.glj waiting got interrupt true
Next example: Exit.
A hands-on tour in the style of Go by Example. Glojure is a Clojure interpreter hosted on Go.