diff --git a/lisp/tramp.el b/lisp/tramp.el index 24b7c45d..50945ccb 100644 --- a/lisp/tramp.el +++ b/lisp/tramp.el @@ -5746,6 +5746,17 @@ Mostly useful to protect BODY from being interrupted by timers." This is needed in order to hide `last-coding-system-used', which is set for process communication also. If the user quits via `C-g', it is propagated up to `tramp-file-name-handler'." + ;; There could be other processes which use the same socket for + ;; communication. This could block the output for the current + ;; process. Read such output first. (Bug#61350) + ;; If `timeout' is nil, `accept-process-output' for `proc' could + ;; block another such a process. So we set `timeout' to 0 then. + (dolist (p (delq proc (process-list))) + (when (tramp-file-name-equal-p + (process-get proc 'vector) (process-get p 'vector)) + (setq timeout (or timeout 0)) + (accept-process-output p 0 nil t))) + (with-current-buffer (process-buffer proc) (let ((inhibit-read-only t) last-coding-system-used