Subject: Re: bug#71709: Fix recent change in tramp-sh-handle-make-process

From: Michael Albinus <[email-masked]>
Date: Sat, 22 Jun 2024 14:02:42 +0200

Michael Albinus <[email-masked]> writes:

Hi Iurie,

> Thanks for the recipe. I've played with it. Most cases, it works as
> expected, but sometimes I see a similar error. Looks like a race
> condition. I'll debug further.

Well, I've found something suspicious in the code. Could you, pls, apply
the appended patch to tramp.el in your Emacs Lisp directory? Since it
changes a macro, you must remove all tramp*.elc files, and run 'make'
afzerwards.

>> Kind Regards,
>> Iurie

Best regards, Michael.

diff --git a/lisp/tramp.el b/lisp/tramp.el
index d9db17ea..f97ed66c 100644
--- a/lisp/tramp.el
+++ b/lisp/tramp.el
@@ -3594,8 +3594,7 @@ that a stederr file is supported.  BODY is the backend specific code."
 		    (not (tramp-equal-remote default-directory stderr)))
 	   (signal 'file-error (list "Wrong stderr" stderr)))

-	 (let ((default-directory tramp-compat-temporary-file-directory)
-	       (name (tramp-get-unique-process-name name))
+	 (let ((name (tramp-get-unique-process-name name))
 	       (buffer
 		(if buffer
 		    (get-buffer-create buffer)
@@ -5058,7 +5057,8 @@ should be set connection-local.")
     ;; Check for `tramp-sh-file-name-handler' and
     ;; `adb-file-name-handler-p', because something is different
     ;; between tramp-sh.el, and tramp-adb.el or tramp-sshfs.el.
-    (let* ((sh-file-name-handler-p (tramp-sh-file-name-handler-p v))
+    (let* ((default-directory tramp-compat-temporary-file-directory)
+	   (sh-file-name-handler-p (tramp-sh-file-name-handler-p v))
 	   (adb-file-name-handler-p (tramp-adb-file-name-p v))
 	   (env (mapcar
 		 (lambda (elt)