diff options
author | Jim Porter <jporterbugs@gmail.com> | 2024-06-25 21:39:35 -0700 |
---|---|---|
committer | Jim Porter <jporterbugs@gmail.com> | 2024-06-25 21:42:28 -0700 |
commit | 1809f6a93efe0ab3ac0f62743c92bd90860ff3ea (patch) | |
tree | a7aca1f01a07a547e26851b3382a829a13209e8b /lisp | |
parent | 8b1841021c0d1ca92cb79443909824519429f75f (diff) | |
download | emacs-1809f6a93efe0ab3ac0f62743c92bd90860ff3ea.tar.gz emacs-1809f6a93efe0ab3ac0f62743c92bd90860ff3ea.tar.bz2 emacs-1809f6a93efe0ab3ac0f62743c92bd90860ff3ea.zip |
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.
(cherry picked from commit da4bc5c9274a6705501e24fb8f2984f5bf5fe099)
Diffstat (limited to 'lisp')
-rw-r--r-- | lisp/eshell/esh-proc.el | 46 |
1 files changed, 24 insertions, 22 deletions
diff --git a/lisp/eshell/esh-proc.el b/lisp/eshell/esh-proc.el index e05590f2542..2ff41c3d409 100644 --- a/lisp/eshell/esh-proc.el +++ b/lisp/eshell/esh-proc.el @@ -530,28 +530,30 @@ PROC is the process that's exiting. STRING is the exit message." (not (process-live-p proc)))) (finish-io (lambda () - (if (or (process-get proc :eshell-busy) - (and wait-for-stderr (car stderr-live))) - (progn - (eshell-debug-command 'process - "i/o busy for process `%s'" proc) - (run-at-time 0 nil finish-io)) - (when data - (ignore-error eshell-pipe-broken - (eshell-output-object - data index handles))) - (eshell-close-handles - status - (when status (list 'quote (= status 0))) - handles) - ;; Clear the handles to mark that we're 100% - ;; finished with the I/O for this process. - (process-put proc :eshell-handles nil) - (eshell-debug-command 'process - "finished external process `%s'" proc) - (if primary - (run-hook-with-args 'eshell-kill-hook proc string) - (setcar stderr-live nil)))))) + (with-current-buffer (process-buffer proc) + (if (or (process-get proc :eshell-busy) + (and wait-for-stderr (car stderr-live))) + (progn + (eshell-debug-command 'process + "i/o busy for process `%s'" proc) + (run-at-time 0 nil finish-io)) + (when data + (ignore-error eshell-pipe-broken + (eshell-output-object + data index handles))) + (eshell-close-handles + status + (when status (list 'quote (= status 0))) + handles) + ;; Clear the handles to mark that we're 100% + ;; finished with the I/O for this process. + (process-put proc :eshell-handles nil) + (eshell-debug-command 'process + "finished external process `%s'" proc) + (if primary + (run-hook-with-args 'eshell-kill-hook + proc string) + (setcar stderr-live nil))))))) (funcall finish-io))) (when-let ((entry (assq proc eshell-process-list))) (eshell-remove-process-entry entry)))))) |