emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master 2a1a7a8524c: Make stty settings configurable in Tramp's make-proc


From: Michael Albinus
Subject: master 2a1a7a8524c: Make stty settings configurable in Tramp's make-process
Date: Sun, 24 Dec 2023 05:35:34 -0500 (EST)

branch: master
commit 2a1a7a8524c0307c09c91e89816b2b2b8bfb85bc
Author: Michael Albinus <michael.albinus@gmx.de>
Commit: Michael Albinus <michael.albinus@gmx.de>

    Make stty settings configurable in Tramp's make-process
    
    * lisp/net/tramp-sh.el (tramp-pipe-stty-settings): New defcustom.
    (tramp-sh-handle-make-process): Use it.  (Bug#62093)
---
 lisp/net/tramp-sh.el | 30 ++++++++++++++++++++++++------
 1 file changed, 24 insertions(+), 6 deletions(-)

diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 064045584ae..1777e2f1ed8 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -2877,7 +2877,16 @@ the result will be a local, non-Tramp, file name."
                (tramp-run-real-handler
                 #'expand-file-name (list localname))))))))))
 
-;;; Remote commands:
+;;; Remote processes:
+
+(defcustom tramp-pipe-stty-settings "-icanon min 1 time 0"
+  "How to prevent blocking read in pipeline processes.
+This is used in `make-process' with `connection-type' `pipe'."
+  :group 'tramp
+  :version "29.3"
+  :type '(choice (const :tag "Use size limit" "-icanon min 1 time 0")
+                (const :tag "Use timeout" "-icanon min 0 time 1")
+                string))
 
 ;; We use BUFFER also as connection buffer during setup.  Because of
 ;; this, its original contents must be saved, and restored once
@@ -3089,12 +3098,21 @@ implementation will be used."
                              ;; otherwise strings larger than 4096
                              ;; bytes, sent by the process, could
                              ;; block, see termios(3) and Bug#61341.
+                             ;; In order to prevent blocking read
+                             ;; from pipe processes, "stty -icanon"
+                             ;; is used.  By default, it expects at
+                             ;; least one character to read.  When a
+                             ;; process does not read from stdin,
+                             ;; like magit, it should set a timeout
+                             ;; instead. See`tramp-pipe-stty-settings'.
+                             ;; (Bug#62093)
                              ;; FIXME: Shall we rather use "stty raw"?
-                             (if (tramp-check-remote-uname v "Darwin")
-                                 (tramp-send-command
-                                  v "stty -icanon min 1 time 0")
-                               (tramp-send-command
-                                v "stty -icrnl -icanon min 1 time 0")))
+                             (tramp-send-command
+                              v (format
+                                 "stty %s %s"
+                                 (if (tramp-check-remote-uname v "Darwin")
+                                     "" "-icrnl")
+                                 tramp-pipe-stty-settings)))
                            ;; `tramp-maybe-open-connection' and
                            ;; `tramp-send-command-and-read' could
                            ;; have trashed the connection buffer.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]