Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by
retagged by

The clojure docs say:

Register INT signal handler. After calling this, Ctrl-C will cause the given function f to be called with a single argument, the signal.
Uses thread-stopper if no function given.

In fact what happens if no function is given is:

   Exception in thread "SIGINT handler" java.lang.IllegalArgumentException: No matching method stop found taking 1 args for class java.lang.Thread
        at clojure.lang.Reflector.invokeMatchingMethod(Reflector.java:127)
        at clojure.lang.Reflector.invokeInstanceMethod(Reflector.java:102)
        at clojure.repl$thread_stopper$fn__11691.invoke(repl.clj:277)
        at clojure.repl$set_break_handler_BANG_$fn__11694.invoke(repl.clj:289)
        at clojure.repl.proxy$java.lang.Object$SignalHandler$d8c00ec7.handle(Unknown Source)
        at jdk.unsupported/sun.misc.Signal$InternalMiscHandler.handle(Signal.java:198)
        at java.base/jdk.internal.misc.Signal$1.run(Signal.java:219)
        at java.base/java.lang.Thread.run(Thread.java:833)

Someone (TimMc in #clojure on libera.chat) suggests that java took out the unary stop function after Java 8, and it's no longer present, so now using set-break-handler! without a provided function doesn't really do anything useful.

1 Answer

0 votes
by
...