]> git.eshelyaron.com Git - emacs.git/commitdiff
Fix some oddities, uncovered by Tramp tests
authorMichael Albinus <michael.albinus@gmx.de>
Wed, 13 May 2020 12:11:18 +0000 (14:11 +0200)
committerMichael Albinus <michael.albinus@gmx.de>
Wed, 13 May 2020 12:11:18 +0000 (14:11 +0200)
* lisp/net/tramp-gvfs.el (tramp-gvfs-enabled): Prevent crash for
older Emacsen.

* lisp/net/tramp.el (tramp-process-running-p): Simplify.

* test/lisp/net/tramp-tests.el (tramp-test28-process-file): Adapt test.
(tramp-test33-environment-variables): Unset "INSIDE_EMACS" initially.

lisp/net/tramp-gvfs.el
lisp/net/tramp.el
test/lisp/net/tramp-tests.el

index f19e510eb670e247a2674ff0cd9b8f0c1653d50a..704d65cd55edbe3cd37839847e57686e35522523 100644 (file)
         (autoload 'zeroconf-init "zeroconf")
         (tramp-compat-funcall 'dbus-get-unique-name :system)
         (tramp-compat-funcall 'dbus-get-unique-name :session)
-        (or (tramp-process-running-p "gvfs-fuse-daemon")
+        (or ;; Until Emacs 25, `process-attributes' could crash Emacs
+            ;; for some processes.  Better we don't check.
+            (<= emacs-major-version 25)
+            (tramp-process-running-p "gvfs-fuse-daemon")
             (tramp-process-running-p "gvfsd-fuse"))))
   "Non-nil when GVFS is available.")
 
index c8fdc5d7285d8c02f50099f4ad1d41885ac67bff..70fb46bb4cbc43c4ebb1a3a0d3b78cca01fea40e 100644 (file)
@@ -3783,7 +3783,8 @@ support symbolic links."
 (defun tramp-handle-start-file-process (name buffer program &rest args)
   "Like `start-file-process' for Tramp files.
 BUFFER might be a list, in this case STDERR is separated."
-  ;; `make-process' knows the `:file-handler' argument since Emacs 27.1 only.
+  ;; `make-process' knows the `:file-handler' argument since Emacs
+  ;; 27.1 only.  Therefore, we invoke it via `tramp-file-name-handler'.
   (tramp-file-name-handler
    'make-process
    :name name
@@ -4857,13 +4858,13 @@ verbosity of 6."
   "Return t if system process PROCESS-NAME is running for `user-login-name'."
   (when (stringp process-name)
     (catch 'result
-      (dolist (pid (tramp-compat-funcall 'list-system-processes))
-       (let ((attributes (process-attributes pid)))
+      (dolist (pid (list-system-processes))
+       (when-let ((attributes (process-attributes pid))
+                  (comm (cdr (assoc 'comm attributes))))
          (and (string-equal (cdr (assoc 'user attributes)) (user-login-name))
-               (when-let ((comm (cdr (assoc 'comm attributes))))
-                 ;; The returned command name could be truncated to 15
-                 ;; characters.  Therefore, we cannot check for `string-equal'.
-                (string-prefix-p comm process-name))
+               ;; The returned command name could be truncated to 15
+               ;; characters.  Therefore, we cannot check for `string-equal'.
+              (string-prefix-p comm process-name)
               (throw 'result t)))))))
 
 (defun tramp-read-passwd (proc &optional prompt)
index 8c3cb8e2e8f405dbd97e153a8f8373afdbb32dd9..de85f83982c28a658a8122b6becf6a17c363d235 100644 (file)
@@ -4208,10 +4208,19 @@ This tests also `make-symbolic-link', `file-truename' and `add-name-to-file'."
            (should (zerop (process-file "true")))
            (should-not (zerop (process-file "false")))
            (should-not (zerop (process-file "binary-does-not-exist")))
-           (should (= (if (getenv "EMACS_HYDRA_CI") 127 42)
-                      (process-file "sh" nil nil nil "-c" "exit 42")))
+           (should
+            (= 42
+               (process-file
+                (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")
+                nil nil nil "-c" "exit 42")))
            ;; Return string in case the process is interrupted.
-           (should (stringp (process-file "sh" nil nil nil "-c" "kill -2 $$")))
+           (should
+            (string-equal
+             "Signal 2"
+             (process-file
+              (if (tramp--test-adb-p) "/system/bin/sh" "/bin/sh")
+              nil nil nil "-c" "kill -2 $$")))
+
            (with-temp-buffer
              (write-region "foo" nil tmp-name)
              (should (file-exists-p tmp-name))
@@ -4874,6 +4883,7 @@ INPUT, if non-nil, is a string sent to the process."
          kill-buffer-query-functions)
 
       ;; Check INSIDE_EMACS.
+      (setenv "INSIDE_EMACS")
       (should
        (string-equal
        (format "%s,tramp:%s" emacs-version tramp-version)