I have a simple single threaded Clojure program that creates a temp file for swapping data. When the program exits normally this file is deleted, however when the program is exited via Ctrl+C, Ctrl+D, or Ctrl+Z that bit of code never executes. I need it to execute regardles sof how the program exits. I know that I need to catch that signal (I've done this before in other languages), but I can't seem to figure out how to do it in Clojure.
相关问题
- Better Sequence Duplicate Remover
- Installation of Leiningen 2.X in Mac OS X
- How can I write a SIG{__DIE__} handler that does n
- What cause info can be readily collected in an iOS
- Questions about Lists and other stuff in Clojure
相关文章
- how to handle os.system sigkill signal inside pyth
- Factor Clojure code setting many different fields
- Does learning one Lisp help in learning the other?
- Better way to nest if-let in clojure
- Idiomatic approach for structuring Clojure source
- Is a “transparent” macrolet possible?
- Detect operating system in Clojure
- Using quote in Clojure
Have a look at the deleteOnExit method in the java.io.File:
I don't know if Clojure has wrapped method for that purpose. In java, you can use Runtime.addShutdownHook()
Update
Here is a simple demo