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

Always perform Eshell process cleanup runs in the Eshell buffer

Previously, some code executed in a timer, which could execute in the
wrong buffer, leading to a hang.

* lisp/eshell/esh-proc.el (eshell-sentinel): Use 'with-current-buffer'
in the timer function.

* test/lisp/eshell/esh-proc-tests.el (eshell-test-value): New variable.
(esh-proc-test/sentinel/change-buffer): New test.
This commit is contained in:
Jim Porter 2024-06-25 21:39:35 -07:00
parent f8399633b4
commit da4bc5c927
2 changed files with 40 additions and 22 deletions

View file

@ -45,6 +45,8 @@
"'")
"A shell command that prints the standard streams connected as TTYs.")
(defvar eshell-test-value nil)
;;; Tests:
@ -130,6 +132,20 @@
(should (= eshell-last-command-status 1))
(should (eq eshell-last-command-result nil)))))
(ert-deftest esh-proc-test/sentinel/change-buffer ()
"Check that changing the current buffer while running a command works.
See bug#71778."
(eshell-with-temp-buffer bufname ""
(with-temp-eshell
(let (eshell-test-value)
(eshell-insert-command
(concat (format "for i in 1 2 {sleep 1; echo hello} > #<%s>; " bufname)
"setq eshell-test-value t"))
(with-current-buffer bufname
(eshell-wait-for (lambda () eshell-test-value))
(should (equal (buffer-string) "hellohello")))
(eshell-match-command-output "echo goodbye" "\\`goodbye\n")))))
;; Pipelines