branch: elpa/magit
commit 5e176cf1063aa67e400a67f7d773a4175f107dd1
Author: Jonas Bernoulli <[email protected]>
Commit: Jonas Bernoulli <[email protected]>
magit-process-kill: First try to interrupt
Closes #5086.
---
docs/CHANGELOG.4 | 3 +++
docs/magit.org | 4 +++-
docs/magit.texi | 4 +++-
lisp/magit-process.el | 20 ++++++++++++++------
4 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/docs/CHANGELOG.4 b/docs/CHANGELOG.4
index fff3ab8972..b0125c391b 100644
--- a/docs/CHANGELOG.4
+++ b/docs/CHANGELOG.4
@@ -31,6 +31,9 @@
- ~magit-file-untrack~, ~magit-file-rename~, ~magit-file-delete~ and
~magit-do-async-shell-command~ can now act on directories. #5247
+- ~magit-process-kill~ now first tries to interrupt the process.
+ If that fails, a second invocation instead kill it. #5086
+
* v4.6.0 2026-07-01
The primary focus of this release are blob-visiting buffers. For
diff --git a/docs/magit.org b/docs/magit.org
index 70bc22a81d..661bc7b9a1 100644
--- a/docs/magit.org
+++ b/docs/magit.org
@@ -1852,7 +1852,9 @@ sections are available. There is one additional command.
- Key: k (magit-process-kill) ::
- This command kills the process represented by the section at point.
+ This command first tries to interrupt the process represented by the
+ section at point. If that fails a second invocation instead kills
+ the process.
- Key: M-x magit-toggle-git-debug ::
diff --git a/docs/magit.texi b/docs/magit.texi
index b05b39efcf..307f60905b 100644
--- a/docs/magit.texi
+++ b/docs/magit.texi
@@ -2176,7 +2176,9 @@ sections are available. There is one additional command.
@item @kbd{k} (@code{magit-process-kill})
@kindex k
@findex magit-process-kill
-This command kills the process represented by the section at point.
+This command first tries to interrupt the process represented by the
+section at point. If that fails a second invocation instead kills
+the process.
@item @kbd{M-x magit-toggle-git-debug}
@findex magit-toggle-git-debug
diff --git a/lisp/magit-process.el b/lisp/magit-process.el
index 9943c6c7e6..475289ab6e 100644
--- a/lisp/magit-process.el
+++ b/lisp/magit-process.el
@@ -401,13 +401,21 @@ optional NODISPLAY is non-nil also display it."
buffer)))
(defun magit-process-kill ()
- "Kill the process at point."
+ "Interrupt or kill the process at point.
+First try to interrupt the process. If that fails a second
+invocation instead kill the process."
(interactive)
- (when-let ((process (magit-section-value-if 'process)))
- (unless (eq (process-status process) 'run)
- (user-error "Process isn't running"))
- (magit-confirm 'kill-process)
- (kill-process process)))
+ (cond-let
+ [[process (magit-section-value-if 'process)]]
+ ((not process)
+ (message "No process at point"))
+ ((not (eq (process-status process) 'run))
+ (message "Process no longer running"))
+ ((not (eq (process-get process 'sigint) t))
+ (magit-confirm 'kill-process)
+ (process-put process 'sigint t)
+ (interrupt-process process))
+ ((kill-process process))))
;;; Synchronous Processes