From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id COfYBcf13WBekQAAgWs5BA (envelope-from ) for ; Thu, 01 Jul 2021 19:05:11 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id sGuDAcf13WC0IgAAbx9fmQ (envelope-from ) for ; Thu, 01 Jul 2021 17:05:11 +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 717A9F9B0 for ; Thu, 1 Jul 2021 19:05:10 +0200 (CEST) Received: from localhost ([::1]:50838 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lz07h-0004jA-Ap for larch@yhetil.org; Thu, 01 Jul 2021 13:05:09 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46004) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lz05e-0003GA-KD; Thu, 01 Jul 2021 13:03:03 -0400 Received: from debbugs.gnu.org ([209.51.188.43]:50312) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lz05e-0004dV-CM; Thu, 01 Jul 2021 13:03:02 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lz05e-00083d-9f; Thu, 01 Jul 2021 13:03:02 -0400 X-Loop: help-debbugs@gnu.org Subject: bug#12972: [PATCH] Avoid regression in mailcap-view-file similar to Bug#44824 Resent-From: Maxim Nikulin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, emacs-orgmode@gnu.org Resent-Date: Thu, 01 Jul 2021 17:03:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 12972 X-GNU-PR-Package: emacs,org-mode X-GNU-PR-Keywords: To: 12972@debbugs.gnu.org Received: via spool by 12972-submit@debbugs.gnu.org id=B12972.162515893730898 (code B ref 12972); Thu, 01 Jul 2021 17:03:02 +0000 Received: (at 12972) by debbugs.gnu.org; 1 Jul 2021 17:02:17 +0000 Received: from localhost ([127.0.0.1]:33625 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lz04v-00082E-Gn for submit@debbugs.gnu.org; Thu, 01 Jul 2021 13:02:17 -0400 Received: from mail-lj1-f179.google.com ([209.85.208.179]:47050) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lz04u-00081z-4p for 12972@debbugs.gnu.org; Thu, 01 Jul 2021 13:02:16 -0400 Received: by mail-lj1-f179.google.com with SMTP id q4so9378020ljp.13 for <12972@debbugs.gnu.org>; Thu, 01 Jul 2021 10:02:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:subject:to:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language; bh=rrfSNKM8QMUYic1UkGs5ueImfm1IoIl0YybtBO3bQ/I=; b=lxEIxAtKLIEb0OcNKbvpS56ShFhwdEbPp/FpD0TLfLGfMziZbBefWXtBBSEWt2X9g1 1Spg6luGFXf4gic5Bg495esaKxWZGHgA9LlddpB0NGjqgDaBjLyGfSx3fbxgaiLEHm6p xHXnRjHFCqIGdpx1tnzH4csy5VhpS4k7Cw7gsbB1S1g3Ber06ii1zsZ3aO7bkTIgBETk OPQ7o4+NiyqjuDJ5kbDUuYgi58ULHHPCI9pbN+AKpVoRS8OAcCyBx7Nx4UFkGkJPBzF+ JMhZTPHIaZFNhBbzNmZXWq4azmVE6jcvftRwOzb9/jOB9+b7kTcpC6nKj+uuklVay9lQ WLsQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:subject:to:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language; bh=rrfSNKM8QMUYic1UkGs5ueImfm1IoIl0YybtBO3bQ/I=; b=NKsmxNPN2yWog/AX0YXHcdweaF6RrLia3ksKo41ywkePV7ODvL21zw5VtGtrvwaaxO LZQ1f2Pv8O5jNXfiEuppMC3ftK4H9hChDG9wIOx3lOo/Ji/pDAXFDPuDrZcCEVagtvPd FTmSGfkgc1uv1m3A+GxAhyMObUGd/wa7IOw9Xq1HVBZSMP75/mnV4PUIbV22CrwqsG8J eJTvLLi6t6EFSGrpVHPFa4UwUFst6HzUfid2Jax6GQLNqGA5kjor/FtOvAQxhH6qVASd y3Zh+S+Q+s+zFFoabSF2ZZ1IYgxLkWVMRI8ekc+mifNOC0QjyajBaYg7kzHn0ENpSQCA IiXw== X-Gm-Message-State: AOAM531ZA9L+m3NMOkSs/PtjUPG1I2XuaLgskZcRq/zVUleLMP/6bdwk /0/4jkV4KhFFYqScx9D41/i3wt6GKP8= X-Google-Smtp-Source: ABdhPJw4/byzn0dwoidheH1J2N4NcRs79RMdrmj+RTUHB/385P8uFpvFmN6p1Jq851dtt0o/i+8bNA== X-Received: by 2002:a2e:b4ce:: with SMTP id r14mr466618ljm.76.1625158928368; Thu, 01 Jul 2021 10:02:08 -0700 (PDT) Received: from [192.168.0.101] (nat-0-0.nsk.sibset.net. [5.44.169.188]) by smtp.googlemail.com with ESMTPSA id t12sm22147lfg.148.2021.07.01.10.02.06 for <12972@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 01 Jul 2021 10:02:07 -0700 (PDT) References: <87r1hmdqek.fsf__16088.3597027109$1622530682$gmane$org@gnus.org> From: Maxim Nikulin Message-ID: Date: Fri, 2 Jul 2021 00:01:59 +0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <87r1hmdqek.fsf__16088.3597027109$1622530682$gmane$org@gnus.org> Content-Type: multipart/mixed; boundary="------------67F3D79E45EE4A50C0EC9894" Content-Language: en-US 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: , 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=1625159110; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to: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=rrfSNKM8QMUYic1UkGs5ueImfm1IoIl0YybtBO3bQ/I=; b=AqNfRF3bU2Qb5iS11F6OYafT3YKf6c/c3CrPBVTTcMPriWgxOzXOjJwu761ZCPIoGTAFiT sOaNohZrlro138csdrGvKD9EqknQ5+jRDkomToANFR0igf61oHHUchb0WEnLdcuGZ6ho4i Cw1NUrsFmxAwLb8E6RvGqvvEkSrYB0o/FxaZ686l+mQufb7eWCyQhKirGqTwLjZqOQhZfZ qIdC+lLF1l4pNicgr+3dyxXtO72raUbis4r40msMR4AeSH6PE22FVzCLdGh7Ocx0QbbODr DevGsaqa2eehk/17flCkHp6FsO3I5P76g323lCIdj2eS+1vNXG5sJMAMubqZxw== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1625159110; a=rsa-sha256; cv=none; b=fyGYBC7qB5C/ziFEk+FNXQOt7HSpASougikd92J3O2KwGCxfSvhHOU1bmEER5Of9xeXc7X 7cnetdUGbyqhTFX/hi5S51iPeFhn9lmTpQ3wDTwUynuZNJDXclfRDeVZlMZAo1TewRRjVs LXZpsJZCdobcWrOR+wlIsZycwxAXzuYXvvQTvu2f5KKvXC8bw6Gy8xAT+NTZSEnuwUzr12 Pjo/I3m5G7080njXuu7/nEr021uoWf5SjfWcyZY+yUcHpjDkRahWt4pqsdbeoyS3QtucTL Dvo0TJv7meCO/r1uaI2Tr9gs+ngwCFxUnzo1OxObBeCPEsM/hyVH62I0c6nRWg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=lxEIxAtK; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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.32 Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20161025 header.b=lxEIxAtK; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=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: 717A9F9B0 X-Spam-Score: -1.32 X-Migadu-Scanner: scn0.migadu.com X-TUID: FW4XvbrzUC90 This is a multi-part message in MIME format. --------------67F3D79E45EE4A50C0EC9894 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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. --------------67F3D79E45EE4A50C0EC9894 Content-Type: text/x-patch; charset=UTF-8; name="0001-mailcap.el-Avoid-xdg-open-silent-failure.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="0001-mailcap.el-Avoid-xdg-open-silent-failure.patch" >From de55b623810736df04641a4d8f6027ccb04caa7f Mon Sep 17 00:00:00 2001 From: Max Nikulin 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 --------------67F3D79E45EE4A50C0EC9894--