Skip to content

Commit d0123fe

Browse files
committed
Couple the lifetime of launchpad and the clojure process
1 parent 5a1a929 commit d0123fe

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

CHANGELOG.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
# Unreleased
22

3-
## Added
4-
53
## Fixed
64

7-
## Changed
5+
- Couple the lifetime of the Clojure process to the lifetime of launchpad, exit
6+
launchpad when the process dies, and kill the process when launchpad exits
87

98
# 0.8.46-alpha (2022-10-07 / 4c68918)
109

@@ -69,4 +68,4 @@ Initial release
6968
- lambdaisland.classpath integration
7069
- Support for cider-nrepl, refactor-nrepl
7170
- Basic support for shadow-cljs cljs nREPL-base REPL
72-
- Auto-connect for Emacs
71+
- Auto-connect for Emacs

src/lambdaisland/launchpad.clj

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,6 @@
318318
(let [args (clojure-cli-args ctx)]
319319
(apply debug (map shellquote args))
320320
(let [process (process args {:env env :out :inherit :err :inherit})]
321-
(future
322-
(System/exit (.waitFor process)))
323321
(assoc ctx :clojure-process process))))
324322

325323
(defn maybe-connect-emacs [{:keys [options nrepl-port project-root] :as ctx}]
@@ -397,12 +395,15 @@
397395
:or {steps default-steps
398396
project-root (find-project-root)}}]
399397

400-
(reduce #(%2 %1)
401-
{:main-opts *command-line-args*
402-
:executable (or executable
403-
(str/replace *file*
404-
(str project-root "/")
405-
""))
406-
:project-root project-root}
407-
steps)
408-
@(promise)))
398+
(let [ctx (reduce #(%2 %1)
399+
{:main-opts *command-line-args*
400+
:executable (or executable
401+
(str/replace *file*
402+
(str project-root "/")
403+
""))
404+
:project-root project-root}
405+
steps)
406+
process (:clojure-process ctx)]
407+
(.addShutdownHook (Runtime/getRuntime)
408+
(Thread. (fn [] (.destroy (:proc process)))))
409+
(System/exit (:exit @process)))))

0 commit comments

Comments
 (0)