emacs-diffs
[Top][All Lists]
Advanced

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

master 8c6a4639318: Handle large process output strings for Tramp


From: Michael Albinus
Subject: master 8c6a4639318: Handle large process output strings for Tramp
Date: Wed, 1 Feb 2023 12:40:27 -0500 (EST)

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

    Handle large process output strings for Tramp
    
    * lisp/net/tramp-sh.el (tramp-sh-handle-make-process):
    Improve handling of connection-type `pipe'.
    
    * test/lisp/tramp-tests.el (tramp-test29-start-file-process)
    (tramp-test30-make-process): Extend tests.
---
 lisp/net/tramp-sh.el         | 22 +++++++++++++++-------
 test/lisp/net/tramp-tests.el |  9 ++++++++-
 2 files changed, 23 insertions(+), 8 deletions(-)

diff --git a/lisp/net/tramp-sh.el b/lisp/net/tramp-sh.el
index 48d91bd733e..d1f723e9807 100644
--- a/lisp/net/tramp-sh.el
+++ b/lisp/net/tramp-sh.el
@@ -3003,13 +3003,21 @@ implementation will be used."
                              (process-put p 'remote-pid pid)
                              (tramp-set-connection-property
                               p "remote-pid" pid))
-                           ;; Disable carriage return to newline
-                           ;; translation.  This does not work on
-                           ;; macOS, see Bug#50748.
-                           (when (and (memq connection-type '(nil pipe))
-                                      (not
-                                       (tramp-check-remote-uname v "Darwin")))
-                             (tramp-send-command v "stty -icrnl"))
+                           (when (memq connection-type '(nil pipe))
+                             ;; Disable carriage return to newline
+                             ;; translation.  This does not work on
+                             ;; macOS, see Bug#50748.
+                             ;; We must also disable buffering,
+                             ;; otherwise strings larger than 4096
+                             ;; bytes, sent by the process, could
+                             ;; block, see termios(3) and
+                             ;; 
<https://github.com/emacs-lsp/lsp-mode/issues/2375#issuecomment-1407272718>.
+                             ;; 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-maybe-open-connection' and
                            ;; `tramp-send-command-and-read' could
                            ;; have trashed the connection buffer.
diff --git a/test/lisp/net/tramp-tests.el b/test/lisp/net/tramp-tests.el
index 338482d2b61..cc93970be28 100644
--- a/test/lisp/net/tramp-tests.el
+++ b/test/lisp/net/tramp-tests.el
@@ -4923,6 +4923,9 @@ This tests also `make-symbolic-link', `file-truename' and 
`add-name-to-file'."
                (should (processp proc))
                (should (equal (process-status proc) 'run))
                (should (equal (process-get proc 'remote-command) command))
+               ;; Give the pipe process a chance to start.
+               (when (memq process-connection-type '(nil pipe))
+                 (sit-for 0.1 'nodisp))
                (process-send-string proc "foo\r\n")
                (process-send-eof proc)
                ;; Read output.
@@ -5194,7 +5197,7 @@ If UNSTABLE is non-nil, the test is tagged as 
`:unstable'."
          ;; `process-connection-type' is taken when
          ;; `:connection-type' is nil.
          (dolist (process-connection-type
-                  (unless connection-type '(nil pipe t pty)))
+                  (if connection-type '(nil pipe t pty) '(nil)))
            (unwind-protect
                (with-temp-buffer
                  (setq command '("hexdump" "-v" "-e" "/1 \"%02X\n\"")
@@ -5210,6 +5213,10 @@ If UNSTABLE is non-nil, the test is tagged as 
`:unstable'."
                  (should (processp proc))
                  (should (equal (process-status proc) 'run))
                  (should (equal (process-get proc 'remote-command) command))
+                 ;; Give the pipe process a chance to start.
+                 (when (or (eq connection-type 'pipe)
+                           (memq process-connection-type '(nil pipe)))
+                   (sit-for 0.1 'nodisp))
                  (process-send-string proc "foo\r\n")
                  (process-send-eof proc)
                  ;; Read output.



reply via email to

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