Problem
I have run the following Clojure code on both my Ubuntu development machine and the BeagleBone Black, and can confirm that it works on the former but not the latter.
(defn setup-shutdown-hook!
[f]
(.addShutdownHook (Runtime/getRuntime) (Thread. f)))
(setup-shutdown-hook!
(fn []
(println "I am no more")))
(defn -main []
(doseq [i (range)]
(Thread/sleep 1000)
(println "Staying alive")))
On the BBB, the shutdown hook does work appropriately in the case of "natural" shutdowns, but not on Ctrl-C. On the Ubuntu machine, it seems to always work.
Is there some explanation for this different behavior? Java versions? System level differences? Is there a workaround for getting the desired behavior?
System details
Ubuntu:
java version "1.7.0_65"
OpenJDK Runtime Environment (IcedTea 2.5.2) (7u65-2.5.2-3~14.04)
OpenJDK 64-Bit Server VM (build 24.65-b04, mixed mode)
Beaglebone (running Angstrom; connected via SSH):
> java -version
java version "1.7.0_60"
Java(TM) SE Runtime Environment (build 1.7.0_60-b19)
Java HotSpot(TM) Client VM (build 24.60-b09, mixed mode)
> uname -a
Linux beaglebone 3.8.13 #1 SMP Wed Sep 4 09:09:32 CEST 2013 armv7l GNU/Linux
P.S. For those of you familiar with Java but not Clojure, the Clojure code above just hooks into the Java methods through it's interop. Hopefully you can test the trans