emacs-elpa-diffs
[Top][All Lists]
Advanced

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

[elpa] externals-release/org 5db61eb 1/2: org.el: Avoid xdg-open silent


From: ELPA Syncer
Subject: [elpa] externals-release/org 5db61eb 1/2: org.el: Avoid xdg-open silent failure
Date: Sun, 21 Mar 2021 13:57:16 -0400 (EDT)

branch: externals-release/org
commit 5db61eb0f9294afdc82cf3165525ac87566da00d
Author: Maxim Nikulin <manikulin@gmail.com>
Commit: Kyle Meyer <kyle@kyleam.com>

    org.el: Avoid xdg-open silent failure
    
    * lisp/org.el (org-open-file): Use 'pipe :connection-type instead of
    'pty to prevent killing of background process on handler exit.
    (Bug#44824)
    
    Problem happens only in some desktop environments where configured
    through `org-file-apps' or mailcap handlers launches actual viewer
    (as defined in .desktop files and obtained from mimeapps.list)
    in background.  E.g. xdg-open invokes "gio open" or kde-open5 for Gnome
    or KDE accordingly and these handlers launches e.g. eog or okular in
    background.  As soon as main process exits, temporary terminal session
    created by `start-process-shell-command' is terminated.  As a result
    background processes receive SIGHUP.
    
    Previously command were executed with no buffer, so the change
    does not affect "needsterminal" and "copiousoutput" mailcap features,
    they are not supported as earlier.
    
    If handler main process fails then show a message with exit reason.
    Output (including error messages) is ignored as before.
    Gtk application tends to report significant amount of failed asserts
    hardly informative for majority of users.
    
    TINYCHANGE
---
 lisp/org.el | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/lisp/org.el b/lisp/org.el
index d0f0d81..a54d688 100644
--- a/lisp/org.el
+++ b/lisp/org.el
@@ -8734,7 +8734,21 @@ If the file does not exist, throw an error."
 
       (save-window-excursion
        (message "Running %s...done" cmd)
-       (start-process-shell-command cmd nil cmd)
+        ;; Handlers such as "gio open" and kde-open5 start viewer in background
+        ;; and exit immediately.  Avoid `start-process' since it assumes
+        ;; :connection-type 'pty and kills children processes with SIGHUP
+        ;; when temporary terminal session is finished.
+        (make-process
+         :name "org-open-file" :connection-type 'pipe :noquery t
+         :buffer nil ; use "*Messages*" for debugging
+         :sentinel (lambda (proc event)
+                     (when (and (memq (process-status proc) '(exit signal))
+                                (/= (process-exit-status proc) 0))
+                       (message
+                        "Command %s: %s."
+                        (mapconcat #'identity (process-command proc) " ")
+                        (substring event 0 -1))))
+         :command (list shell-file-name shell-command-switch cmd))
        (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait))))
      ((or (stringp cmd)
          (eq cmd 'emacs))



reply via email to

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