File tree 2 files changed +27
-7
lines changed
2 files changed +27
-7
lines changed Original file line number Diff line number Diff line change 1
1
# Unreleased
2
2
3
- ## Added
4
-
5
- ## Fixed
6
-
7
3
## Changed
8
4
5
+ - Make sure child processes are killed when launchpad receives a INT/TERM/KILL signal
6
+
9
7
# 0.29.135-alpha (2024-06-03 / 00df813)
10
8
11
9
## Added
@@ -231,4 +229,4 @@ Initial release
231
229
- lambdaisland.classpath integration
232
230
- Support for cider-nrepl, refactor-nrepl
233
231
- Basic support for shadow-cljs cljs nREPL-base REPL
234
- - Auto-connect for Emacs
232
+ - Auto-connect for Emacs
Original file line number Diff line number Diff line change 15
15
(java.net ServerSocket)
16
16
(java.util.concurrent TimeUnit)))
17
17
18
+ (defonce processes (atom []))
19
+
20
+ (defn cleanup [sig]
21
+ (println " Received" (str " SIG" sig))
22
+ (doseq [process @processes]
23
+ (print " Killing" (.pid process))
24
+ (flush )
25
+ (.destroy process)
26
+ (println " ->" (.waitFor process))
27
+ (flush ))
28
+ (System/exit 0 ))
29
+
30
+ (defmacro set-signal-handler!
31
+ [signal f]
32
+ `(sun.misc.Signal/handle
33
+ (sun.misc.Signal. ~signal)
34
+ (proxy [sun.misc.SignalHandler] []
35
+ (handle [signal#] (~f signal#)))))
36
+
37
+ (set-signal-handler! " INT" cleanup)
38
+ (set-signal-handler! " TERM" cleanup)
39
+ (set-signal-handler! " KILL" cleanup)
40
+
18
41
(def cli-opts
19
42
[[" -h" " --help" ]
20
43
[" -v" " --verbose" " Print debug information" ]
518
541
color (mod (hash (or prefix (first cmd))) 8 )
519
542
prefix (str " [" (ansi-fg (+ 30 color) (or prefix (first cmd))) " ] " )
520
543
process (pipe-process-output (.start proc-builder) prefix)
544
+ _ (swap! processes conj process)
521
545
ctx (update ctx :processes (fnil conj []) process)]
522
546
(when show-command?
523
547
(apply println (str prefix " $" ) (map shellquote cmd)))
617
641
after-steps
618
642
end-steps)))
619
643
processes (:processes ctx)]
620
- (.addShutdownHook (Runtime/getRuntime )
621
- (Thread. (fn [] (run! #(.destroy %) processes))))
622
644
(System/exit (apply min (for [p processes]
623
645
(.waitFor p))))))
You can’t perform that action at this time.
0 commit comments