From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Maxim Nikulin Newsgroups: gmane.emacs.bugs Subject: bug#44824: [PATCH] org.el: Avoid xdg-open silent failure Date: Fri, 19 Feb 2021 23:45:55 +0700 Message-ID: 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> <83a6s15t51.fsf__31631.6350990505$1613659778$gmane$org@gnu.org> <1a7077ea-c3ad-be6b-6303-f3ed225ec6f8@gmail.com> <83blcg2jn0.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="38330"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 Cc: 44824@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Feb 19 20:23:16 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lDBMw-0009rQ-WD for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Feb 2021 20:23:15 +0100 Original-Received: from localhost ([::1]:35374 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lDBMv-0002on-DE for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 19 Feb 2021 14:23:13 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lD8vm-00078f-Os; Fri, 19 Feb 2021 11:47:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]:38730) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lD8vl-0004fZ-PX; Fri, 19 Feb 2021 11:47:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lD8vl-0000IV-NU; Fri, 19 Feb 2021 11:47:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Maxim Nikulin Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org, emacs-orgmode@gnu.org Resent-Date: Fri, 19 Feb 2021 16:47:01 +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 Original-Received: via spool by 44824-submit@debbugs.gnu.org id=B44824.16137531711047 (code B ref 44824); Fri, 19 Feb 2021 16:47:01 +0000 Original-Received: (at 44824) by debbugs.gnu.org; 19 Feb 2021 16:46:11 +0000 Original-Received: from localhost ([127.0.0.1]:50266 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lD8uw-0000Gp-Pl for submit@debbugs.gnu.org; Fri, 19 Feb 2021 11:46:11 -0500 Original-Received: from mail-lj1-f176.google.com ([209.85.208.176]:40012) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lD8us-0000G8-Rv for 44824@debbugs.gnu.org; Fri, 19 Feb 2021 11:46:09 -0500 Original-Received: by mail-lj1-f176.google.com with SMTP id y7so21208779lji.7 for <44824@debbugs.gnu.org>; Fri, 19 Feb 2021 08:46:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:subject:cc:newsgroups:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=85o83rAqlrVSdP2ZZPtfGpoOUteliKI8ata+sc2XTn4=; b=NZYmQkxubMDoc+sJOvy6s6w1K6koiGMrPUje2B6hGGzvXL7uOIp/HQ9YUyKeygKwSx mXHACqN8TVKzfkeMQzj9IvFQ4RNaUFARoHCfVhjjbF2bjXXMpESDsxV/6XHSAB6hy1n3 XjAwmVVY6lNdAeT1oxEAGG9wS2P4frpRsWOROir/UBf3oE6+Tg2NXYNQNLzW+gXNAZKw NGmvlYwx/GTcUaowqzH4bZtKwzpEdDet9jIxLBdf8JQgUYBIMc4uHsUx5L4iYnNTUtX9 BAAvHy8S0XF1gDqcXzDP2XCgA+wGJ+gZzPBdAZIT32m7K99hp4XeFADgcESvE1tZvQvr HRyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:cc:newsgroups:references:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=85o83rAqlrVSdP2ZZPtfGpoOUteliKI8ata+sc2XTn4=; b=jpNSedxBuJwbgxXDci/VQnbGGj1rY4b2f+eDAVD37QBrETcD341bKXsXWIXwvBcHCi 8r5/yy0DkZa7PnxeD0HZwcnWbbOAO0quU0vDtSV66LVmcRKl62mP+5OPhVFEnbmvVx7a dr5f4OD07Fo0vxY1/AiAxqBfNBX/wElejoj/xwCBrrutgRijLSkiM0BVD3YBu2vVw4B0 WeVnMBpyA2Xc8jvoMnace22sndeYWbkio91q6mdT5KZy8BBl0aqLf/wTuddgkBpwr3mT y7ZAkcwCKvsxxkWGhbXj1K7Tj+3+4FBAKnZgwGPj1pyRGoHs9xtoLx1fDmSiBZkDiNyk M+Jg== X-Gm-Message-State: AOAM531UMmFrg6TyE4o1SsmiBD1DFw9yO+H+IHj8LQPDEezE/uGCEqhV 9i15yWW70+VN8Vobp9JJThXbquo+LGE= X-Google-Smtp-Source: ABdhPJzRzgMB5zci7e7ZjusC9pKYCyWdu3OveI+W8ayeVr18EqjEBU2Q4JvxNzD2o5zRwQwkIgJiYw== X-Received: by 2002:a2e:7a07:: with SMTP id v7mr6064630ljc.463.1613753160324; Fri, 19 Feb 2021 08:46:00 -0800 (PST) Original-Received: from [192.168.0.101] (nat-0-0.nsk.sibset.net. [5.44.169.181]) by smtp.googlemail.com with ESMTPSA id u25sm1027862ljo.98.2021.02.19.08.45.59 for <44824@debbugs.gnu.org> (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 19 Feb 2021 08:45:59 -0800 (PST) X-Google-Original-From: Maxim Nikulin Original-Newsgroups: gmane.emacs.orgmode In-Reply-To: <83blcg2jn0.fsf@gnu.org> Content-Language: en-US X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-Mailman-Approved-At: Fri, 19 Feb 2021 14:22:57 -0500 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:200377 Archived-At: On 19/02/2021 21:54, Eli Zaretskii wrote: >> From: Maxim Nikulin >> Date: Fri, 19 Feb 2021 19:29:49 +0700 >> >>> On Windows Emacs always uses pipes, because we don't have PTYs there. >>> And there's no xdg-open on MS-Windows anyway, so it's a moot point. >> >> Should I consider your response as a suggestion to remove the `if' >> related to `system-type'? > > Yes, that 'if' isn't necessary. Let's wait for comments comments from org developers. I do not mind to remove the `if' but they could ask for other changes. >> If I remember correctly, on windows it is possible to communicate with a >> process through stdin and stdout only if the application is compiled as >> a *console* one. > > That's true. But in this case we don't really want to communicate > with the sub-process, do we? We just want to invoke it and let it > run. So the fact that there's no way of communicating with the > sub-process is not important here, as the pipes will not be used. We > just need to specify pipes because that works around the problem with > xdg-open. The reason to switch to pipe process here is to avoid side effects of *terminal session*. PTY is redundant here. Pipe process is the only alternative available in emacs. Currently there is no data exchange with subprocess. Reading of stderr and stdout from the handler and its descendants could be useful to realize a cause of a problem when it happens. At least on linux it is enough to specify some buffer instead of `nil' or add a :filter function. The reason why I did not make such change is that Gtk applications tends to report significant number of failed asserts. I do not like to pollute the "*Messages*" buffer. I am in doubts if a dedicated buffer should be created for such purpose. Reading of stdout could be useful in mailcap handlers e.g. to display text from PDF file when only text terminal is available (no X11 or wayland). Currently emacs ignores "needsterminal" and "copiousoutput" flags in mailcap. Example of an entry for PDF: application/pdf; pdftotext -layout %s -; test=test -z "$DISPLAY"; copiousoutput Likely only a small part of users could benefit from such feature. >> "start file.pdf" executed in cmd.exe launches an application that does >> not block command prompt. In this sense it similar to background >> processes launched by kde-open5 or "gio open". However I am unaware if >> there is something similar to process groups on windows that leads to >> termination of all group members when leader process finishes. > > Things are fairly similar on Windows. But is this really relevant to > the issue at hand? There's no xdg-open on Windows, so whatever > problems you had with xdg-open will never happen on Windows. the > proposed patch fixes the problem only on systems where org.el invokes > the PDF viewer via xdg-open. Right? 1. It is not a problem of namely xdg-open. It is (mostly reasonable but with some caveats however) specific of DE-specific handlers as "gio open" and kde-open5. They exit just after spawning of a process with actual handler. (Just like "start file.pdf" on windows.) I am afraid that I could break something on windows, so I would prefer that somebody will test the changes on non-linux systems. 2. It is not specific to PDF files, the problem could happen with any format if wrapper handler such as "gio open" is invoked instead of e.g. direct execution of eog.