]> git.eshelyaron.com Git - emacs.git/commitdiff
Handle large process output strings for Tramp
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 1 Feb 2023 17:40:11 +0000 (18:40 +0100)
committerMichael Albinus <michael.albinus@gmx.de>
Wed, 1 Feb 2023 17:40:11 +0000 (18:40 +0100)
* 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
test/lisp/net/tramp-tests.el

index 48d91bd733ec6d246eebf45b2b4799074a57488c..d1f723e9807184818cf02f58c2461a9aa132f065 100644 (file)
@@ -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.
index 338482d2b61b2833f95e88c83494c24c24646c15..cc93970be28341dcb1a987765cffc7baf145dd15 100644 (file)
@@ -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.