1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2025-12-15 10:30:25 -08:00

Improve implementation of built-in Eshell "kill" command

* lisp/eshell/esh-proc.el (eshell/kill): Fix handling of commands like
"kill 123".  Use REMOTE when signalling PIDs in remote directories.
Signal using process objects when possible.  Report errors when failing
to signal.

* test/lisp/eshell/esh-proc-tests.el (esh-proc-test/kill/process-id)
(esh-proc-test/kill/process-object): New tests (bug#72013).
This commit is contained in:
Jim Porter 2024-07-18 11:43:34 -07:00
parent c7a498260c
commit 259f4613bd
2 changed files with 45 additions and 27 deletions

View file

@ -344,6 +344,30 @@ write the exit status to the pipe. See bug#54136."
output-start (eshell-end-of-output))
""))))))
(ert-deftest esh-proc-test/kill/process-id ()
"Test killing processes with the \"kill\" built-in using PIDs."
(skip-unless (executable-find "sleep"))
(with-temp-eshell
(eshell-insert-command "sleep 100 &")
(string-match (rx (group (+ digit)) eol) (eshell-last-output))
(let ((pid (match-string 1 (eshell-last-output))))
(should (= (length eshell-process-list) 1))
(eshell-insert-command (format "kill %s" pid))
(should (= eshell-last-command-status 0))
(eshell-wait-for-subprocess t)
(should (= (length eshell-process-list) 0)))))
(ert-deftest esh-proc-test/kill/process-object ()
"Test killing processes with the \"kill\" built-in using process objects."
(skip-unless (executable-find "sleep"))
(with-temp-eshell
(eshell-insert-command "sleep 100 &")
(should (= (length eshell-process-list) 1))
(eshell-insert-command "kill (caar eshell-process-list)")
(should (= eshell-last-command-status 0))
(eshell-wait-for-subprocess t)
(should (= (length eshell-process-list) 0))))
;; Remote processes