From: Maxim Nikulin <manikulin@gmail.com> To: 12972@debbugs.gnu.org Subject: bug#12972: [PATCH] Avoid regression in mailcap-view-file similar to Bug#44824 Date: Fri, 2 Jul 2021 00:01:59 +0700 [thread overview] Message-ID: <cdb70599-1082-fd9b-0927-ec811d3a6ee8@gmail.com> (raw) In-Reply-To: <87r1hmdqek.fsf__16088.3597027109$1622530682$gmane$org@gnus.org> [-- Attachment #1: Type: text/plain, Size: 268 bytes --] On 01/06/2021 13:56, Lars Ingebrigtsen wrote: > So I've now added this to Emacs 28 under the name `mailcap-view-file'. I am attaching a patch similar to proposed to Org mode that should help to avoid obscure failures of viewers due to unnecessary terminal sessions. [-- Attachment #2: 0001-mailcap.el-Avoid-xdg-open-silent-failure.patch --] [-- Type: text/x-patch, Size: 2822 bytes --] From de55b623810736df04641a4d8f6027ccb04caa7f Mon Sep 17 00:00:00 2001 From: Max Nikulin <manikulin@gmail.com> Date: Thu, 1 Jul 2021 23:41:16 +0700 Subject: [PATCH] mailcap.el: Avoid xdg-open silent failure * lisp/net/mailcap.el (mailcap-view-file): Use 'pipe :connection-type instead of 'pty to prevent killing of background process on handler exit. Avoid regression similar to Bug#44824. Problem happens only in some desktop environments where mailcap handler 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 launch 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 as well, so the change does not affect "needsterminal" and "copiousoutput" mailcap features, they are not supported as earlier. If main process of the handler fails then show a message with exit reason. Output (including error messages) is ignored as before. Gtk applications tend to report significant amount of failed asserts hardly informative for majority of users. --- lisp/net/mailcap.el | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lisp/net/mailcap.el b/lisp/net/mailcap.el index 54f7f416ab..a53e385662 100644 --- a/lisp/net/mailcap.el +++ b/lisp/net/mailcap.el @@ -1177,7 +1177,23 @@ See \"~/.mailcap\", `mailcap-mime-data' and related files and variables." (shell-quote-argument (convert-standard-filename file)) command nil t)) - (start-process-shell-command command nil command))) + ;; 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 (Bug#44824). + ;; An alternative is `process-connection-type' let-bound to nil for + ;; `start-process-shell-command' call (with no chance to report failure). + (make-process + :name "mailcap-view-file" :connection-type 'pipe :noquery t + :buffer nil ; "*Messages*" may be suitable 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 command)))) (provide 'mailcap) -- 2.25.1
next prev parent reply other threads:[~2021-07-01 17:05 UTC|newest] Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <F3C1A7E58B2441F7A674239043AC031A@us.oracle.com> 2021-06-01 6:56 ` bug#12972: 24.3.50; Move `org-open-file' and associated code out of Org mode Lars Ingebrigtsen [not found] ` <87r1hmdqek.fsf__16088.3597027109$1622530682$gmane$org@gnus.org> 2021-06-02 16:20 ` Maxim Nikulin 2021-07-01 17:01 ` Maxim Nikulin [this message] 2021-07-01 18:38 ` bug#12972: [PATCH] Avoid regression in mailcap-view-file similar to Bug#44824 Eli Zaretskii [not found] ` <835yxtlw14.fsf__2546.8955327355$1625164803$gmane$org@gnu.org> 2021-07-02 12:21 ` Maxim Nikulin 2021-07-02 12:37 ` Eli Zaretskii [not found] ` <837di8ki24.fsf__46278.4886871063$1625229533$gmane$org@gnu.org> 2021-07-02 16:24 ` Maxim Nikulin 2021-07-02 17:28 ` Eli Zaretskii [not found] ` <831r8gk4m0.fsf__14172.0669272885$1625246977$gmane$org@gnu.org> 2021-07-03 11:29 ` Maxim Nikulin 2021-07-03 11:56 ` Eli Zaretskii [not found] ` <83im1ripaz.fsf__31901.4239286602$1625313464$gmane$org@gnu.org> 2021-07-04 13:37 ` Maxim Nikulin 2021-07-04 13:49 ` Eli Zaretskii 2021-07-05 13:12 ` Maxim Nikulin 2021-07-05 15:23 ` Eli Zaretskii 2021-07-30 12:01 ` bug#12972: 24.3.50; Move `org-open-file' and associated code out of Org mode Lars Ingebrigtsen 2021-07-30 12:24 ` Maxim Nikulin 2021-07-30 12:42 ` Lars Ingebrigtsen
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style List information: https://www.orgmode.org/ * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=cdb70599-1082-fd9b-0927-ec811d3a6ee8@gmail.com \ --to=manikulin@gmail.com \ --cc=12972@debbugs.gnu.org \ --subject='Re: bug#12972: [PATCH] Avoid regression in mailcap-view-file similar to Bug#44824' \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
Code repositories for project(s) associated with this inbox: https://git.savannah.gnu.org/cgit/emacs/org-mode.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).