Skip to content

Commit 7daf4e9

Browse files
benedekfazekasbbatsov
authored andcommitted
[Fix #390] Implement a workaround for orphaned Java process on Windows (#2051)
After quitting the REPL child Java processes on Windows weren't properly killed (likely an Emacs bug). Seems that `interrupt-process` does the trick, so now we use `interrupt-process` instead of `kill-process` if the OS is Windows.
1 parent d55768a commit 7daf4e9

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
* [#1895](https://github.com/clojure-emacs/cider/issues/1895): Connect to the same host:port after `cider-restart` if the connection was established with `cider-connect`.
6161
* [#1881](https://github.com/clojure-emacs/cider/issues/1881): Add `cider-cljs-boot-repl` and `cider-cljs-gradle-repl` defcustom and hook `boot-cljs-repl`.
6262
* [#1997](https://github.com/clojure-emacs/cider/pull/1997): Fix a nil error when loading a code buffer and the error buffer is visible.
63+
* [#390](https://github.com/clojure-emacs/cider/issues/390): Workaround for orphaned java process on windows machine after quitting the REPL.
6364

6465
## 0.14.0 (2016-10-13)
6566

nrepl-client.el

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,13 @@ If NO-ERROR is non-nil, show messages instead of throwing an error."
616616

617617

618618
;;; Client: Process Handling
619+
(defun nrepl--kill-process (proc)
620+
"Kill PROC using the appropriate, os specific way.
621+
Implement a workaround to clean up an orphaned JVM process left around
622+
after exiting the REPL on some windows machines."
623+
(if (memq system-type '(cygwin windows-nt))
624+
(interrupt-process proc)
625+
(kill-process proc)))
619626

620627
(defun nrepl--maybe-kill-server-buffer (server-buf)
621628
"Kill SERVER-BUF and its process, subject to user confirmation.
@@ -628,7 +635,7 @@ Do nothing if there is a REPL connected to that server."
628635
(let ((proc (get-buffer-process server-buf)))
629636
(when (process-live-p proc)
630637
(set-process-query-on-exit-flag proc nil)
631-
(kill-process proc))
638+
(nrepl--kill-process proc))
632639
(kill-buffer server-buf)))))
633640

634641
;; `nrepl-start-client-process' is called from `nrepl-server-filter'. It

0 commit comments

Comments
 (0)