From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id WHe1AswfVGBFXAAA0tVLHw (envelope-from ) for ; Fri, 19 Mar 2021 03:51:40 +0000 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id UPkSOssfVGCsXwAAB5/wlQ (envelope-from ) for ; Fri, 19 Mar 2021 03:51:39 +0000 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 38DDA2566F for ; Fri, 19 Mar 2021 04:51:39 +0100 (CET) Received: from localhost ([::1]:46210 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lN6Aj-0003ka-BD for larch@yhetil.org; Thu, 18 Mar 2021 23:51:37 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:37172) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lN6AA-0003kC-Bg; Thu, 18 Mar 2021 23:51:02 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:36876) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lN6AA-0006Ww-4H; Thu, 18 Mar 2021 23:51:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lN6AA-0007AC-2A; Thu, 18 Mar 2021 23:51:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#44824: [PATCH] org.el: Avoid xdg-open silent failure Resent-From: Kyle Meyer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, emacs-orgmode@gnu.org Resent-Date: Fri, 19 Mar 2021 03:51:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 44824 X-GNU-PR-Package: emacs,org-mode X-GNU-PR-Keywords: moreinfo To: Maxim Nikulin Received: via spool by 44824-submit@debbugs.gnu.org id=B44824.161612581227469 (code B ref 44824); Fri, 19 Mar 2021 03:51:02 +0000 Received: (at 44824) by debbugs.gnu.org; 19 Mar 2021 03:50:12 +0000 Received: from localhost ([127.0.0.1]:48422 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lN69M-00078z-2L for submit@debbugs.gnu.org; Thu, 18 Mar 2021 23:50:12 -0400 Received: from out2.migadu.com ([188.165.223.204]:23209) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lN69J-00078m-Ki for 44824@debbugs.gnu.org; Thu, 18 Mar 2021 23:50:10 -0400 X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kyleam.com; s=key1; t=1616125807; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=x+6upk38U8HOTObXgg1ouoVGLNCPmX56juVRAw/qJG8=; b=0KDw1p5LishMbs1CI0I++wEPIpqTWZlfdzf8skP4YTgm+PnadcTTeog30q9EY2Y5xRvQuO nJ2UJb5GSskbANus7Scv6OsrkA3LwonCNL7D2KuYvtyB6rUT7Wq6N6IBi9wN53WHTd4ewb 36NKBRkOA4F2zngtBtmLrN5igr+QXngrpIrXNV3bAkizoZNbgY7kgopVTyeWh2Ad4p6Ob3 SzTbIXc8G0H5D4au9bNhGaLfPydxdkGN7beFpYYOeDhj+PSfqOrnclwQqVauDiBJwzeErt SHzCIDKIYT2aWXfRuzZ6oDjk9HgCY4vfPT+3mzPZla/LMRcPHRurtBpY/VPpmA== From: Kyle Meyer In-Reply-To: References: <87y2gfcape.fsf_-_@gnus.org> <87a6st7oi1.fsf@gnus.org> <108399a5-66ad-eee6-572b-b3f2181e4e6c@gmail.com> <87lfccxs5a.fsf@gnus.org> <875z3f2bwx.fsf@gnus.org> <838s8aak8j.fsf@gnu.org> <83sg6i8rht.fsf@gnu.org> <5f1a0018-56a4-7f00-68bc-eeb93631f102@gmail.com> <83lfca8k4e.fsf@gnu.org> <83y2g96ta6.fsf@gnu.org> <7635bde2-8590-f555-0d3b-7fa818d812c6@gmail.com> <83o8h56p7o.fsf__8661.17158891342$1612110869$gmane$org@gnu.org> Date: Thu, 18 Mar 2021 23:50:06 -0400 Message-ID: <87zgyzls41.fsf@kyleam.com> MIME-Version: 1.0 Content-Type: text/plain X-Migadu-Auth-User: kyle@kyleam.com X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: emacs-orgmode@gnu.org List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eli Zaretskii , 44824@debbugs.gnu.org Errors-To: emacs-orgmode-bounces+larch=yhetil.org@gnu.org Sender: "Emacs-orgmode" X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1616125899; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:resent-cc:resent-from:resent-sender: resent-message-id:in-reply-to:in-reply-to:references:references: list-id:list-help:list-unsubscribe:list-subscribe:list-post: dkim-signature; bh=x+6upk38U8HOTObXgg1ouoVGLNCPmX56juVRAw/qJG8=; b=NORTfQI+ID3OvL3ojAsw7ey8qA6lzjriiUSMCY9yyNaPlMvEOxihOAfC8Ds5s9qT5jFVVC 9AYamA/yrFhj4n7NMD/uesO7obrjuuyPKEHRb6kFI+GDqERs6dxf7jLGeA+JOxQ+TIVo7l gdTrVwYkIennzO1mGZt/YKogn6r4X+/HMcJc4418iF/WTms0NrtK3rB+UYPG65Tk30HoeH c92UBWOE0AhNrQ5iaOGY5IYoi7CmnGSvsqVyb4hiap06yQ6sg54vr4Brj3LFzQBPWOQqdy lHlzMPha+FOibY4dXwIUDajvSClJmJSTZn41sEwr3vU+aKpEkMXXJ+c+Z2pyVw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1616125899; a=rsa-sha256; cv=none; b=qZHnRk1K6rzAOSPq6mVvkzi4dLIl8xvdYm9l1AXry+pl3QAyyTO7vpP4A7NstQKMxiYbpQ CO/W7Kd12W068vZI638vc56Hb+DR2R5SSw9G+mG5Fgyx2WXgc0PsHSFz3RbTy8DO2JYBpW 0PNJ/EsSnDFZN++0G1COWSmmMV8TXUHzrUdP76ncOha+gEIoNPSZ/55DhRYVOO7NyKLGBH +XIPwBLB2mtV+hBfMBOCudEdiUGmogM5JKCsoZrhl8CKb8zg9LtB0kB4pEO9Q29GL97fCa nv0Xte73uGD3jNW8m6rljsk3OM4JTGx7QQadMs6wbeUdLCGH0EJsXiqyTXgNMw== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=kyleam.com header.s=key1 header.b=0KDw1p5L; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Spam-Score: -1.41 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=kyleam.com header.s=key1 header.b=0KDw1p5L; dmarc=none; spf=pass (aspmx1.migadu.com: domain of emacs-orgmode-bounces@gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=emacs-orgmode-bounces@gnu.org X-Migadu-Queue-Id: 38DDA2566F X-Spam-Score: -1.41 X-Migadu-Scanner: scn0.migadu.com X-TUID: cSwSykzRjMHH Maxim Nikulin writes: > 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. > > 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. Thanks for the detailed commit message. A few comments in addition to Eli's advice to drop the (eq system-type 'gnu/linux) condition... > diff --git a/lisp/org.el b/lisp/org.el > index 7d8733448..a199a65c9 100644 > --- a/lisp/org.el > +++ b/lisp/org.el > @@ -8645,6 +8645,15 @@ opened in Emacs." > (when add-auto-mode > (mapcar (lambda (x) (cons (car x) 'emacs)) auto-mode-alist)))) > > +(defun org--error-process-sentinel (proc event) > + "Show a message if process failed (exited with non-zero code > +or killed by a signal. Pass the function as :SENTINEL argument Please rework the first sentence so that it fits on the first line, though I'd be in favor dropping the function and using a lambda in the make-process call. > +of `make-process'." > + (unless (string-match "finished" event) There's no need for substring matching, right? So it could be (equal event "finished\n") Or perhaps (when (and (memq (process-status proc) '(exit signal)) (/= (process-exit-status proc) 0)) ...) > + (message "Command %s: %s." > + (mapconcat 'identity (process-command proc) " ") s/'identity/#'identity/ > + (substring event 0 -1)))) > + > ;;;###autoload > (defun org-open-file (path &optional in-emacs line search) > "Open the file at PATH. > @@ -8766,7 +8775,17 @@ If the file does not exist, throw an error." > > (save-window-excursion > (message "Running %s...done" cmd) > - (start-process-shell-command cmd nil cmd) > + (if (eq system-type 'gnu/linux) > + ;; Handlers as "gio open" and kde-open5 start viewer in background s/as/such as/ ? > + ;; and exit immediately. Avoid start-process since it assumes ^ missing space > + ;; :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 s/'t/t/ > + :buffer nil ; use "*Messages*" for debugging > + :sentinel 'org--error-process-sentinel > + :command (list shell-file-name shell-command-switch cmd)) > + (start-process-shell-command cmd nil cmd)) > (and (boundp 'org-wait) (numberp org-wait) (sit-for org-wait)))) > ((or (stringp cmd) > (eq cmd 'emacs)) Thanks.