From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp1 ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms11 with LMTPS id MPpKK4S/BWAldAAA0tVLHw (envelope-from ) for ; Mon, 18 Jan 2021 17:04:04 +0000 Received: from aspmx1.migadu.com ([2001:41d0:2:4a6f::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp1 with LMTPS id yArtJoS/BWCvbwAAbx9fmQ (envelope-from ) for ; Mon, 18 Jan 2021 17:04:04 +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 230959403AE for ; Mon, 18 Jan 2021 17:04:04 +0000 (UTC) Received: from localhost ([::1]:41704 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l1Xwg-0005Us-R5 for larch@yhetil.org; Mon, 18 Jan 2021 12:04:02 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:35530) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1XSP-0002tS-IA for emacs-orgmode@gnu.org; Mon, 18 Jan 2021 11:32:46 -0500 Received: from ciao.gmane.io ([116.202.254.214]:54392) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l1XSO-0001f7-3y for emacs-orgmode@gnu.org; Mon, 18 Jan 2021 11:32:45 -0500 Received: from list by ciao.gmane.io with local (Exim 4.92) (envelope-from ) id 1l1XSM-00097M-78 for emacs-orgmode@gnu.org; Mon, 18 Jan 2021 17:32:42 +0100 X-Injected-Via-Gmane: http://gmane.org/ To: emacs-orgmode@gnu.org From: Maxim Nikulin Subject: Re: [BUG] [C-u C-u C-c C-o] open link with external program invalid to open file Date: Mon, 18 Jan 2021 23:32:35 +0700 Message-ID: References: <87ftazz9q0.fsf@gmail.com> <87lfho7ja2.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: <87lfho7ja2.fsf@gnu.org> Content-Language: en-US Received-SPF: pass client-ip=116.202.254.214; envelope-from=geo-emacs-orgmode@m.gmane-mx.org; helo=ciao.gmane.io X-Spam_score_int: 27 X-Spam_score: 2.7 X-Spam_bar: ++ X-Spam_report: (2.7 / 5.0 requ) BAYES_00=-1.9, DKIM_ADSP_CUSTOM_MED=0.001, FORGED_GMAIL_RCVD=1, FORGED_MUA_MOZILLA=2.309, FREEMAIL_FORGED_FROMDOMAIN=0.248, FREEMAIL_FROM=0.001, GAPPY_SUBJECT=0.1, HEADER_FROM_DIFFERENT_DOMAINS=0.248, NICE_REPLY_A=-0.194, NML_ADSP_CUSTOM_MED=0.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-orgmode@gnu.org X-Mailman-Version: 2.1.23 Precedence: list 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 X-Migadu-Spam-Score: -1.76 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=fail reason="SPF not aligned (relaxed), No valid DKIM" 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: 230959403AE X-Spam-Score: -1.76 X-Migadu-Scanner: scn1.migadu.com X-TUID: jnhpM/0FZfXk On 05/09/2020 14:52, Bastien wrote: > > stardiviner writes: > >> When I press =[C-u C-u C-c C-o]= to open an image file link with system external >> program. It can't open the image file. > > I cannot reproduce the problem here. > > If you still have this issue, can you provide a minimal reproducible > example? Christopher Miles recently posted a link to askubuntu that shed some light on the problem. I have compared the following commands: (start-process-shell-command "xdg-open" nil "xdg-open /usr/share/icons/gnome/256x256/actions/stock_print.png") (start-process-shell-command "eog" nil "eog /usr/share/icons/gnome/256x256/actions/stock_print.png") The latter works in my (test) case (Ubuntu-20.04, ubuntu session - gnome), the former does not. If I do not mistake, start-process-shell-command is what org mode uses to open file. Meaningful lines from strace of the emacs process 24108 21:39:51 execve("/bin/bash", ["/bin/bash", "-c", "xdg-open /usr/share/icons/gnome/"...], 0x7ffcb1c1fdb0 /* 55 vars */ 24116 21:39:51 execve("/usr/bin/eog", ["eog", "/usr/share/icons/gnome/256x256/a"...], 0x55d009672ec8 /* 57 vars */ 24108 21:39:51 +++ exited with 0 +++ 24116 21:39:51 +++ killed by SIGHUP +++ I think, the problem is that start-process-shell-command creates a "pty" process. As soon as main command exits, all children, that belong to the same terminal session created by emacs for the process, got killed. Calling eog directly works because of it does not attempt to go to background or demonize. The solution could be (make-process :connection-type 'pipe ...). Personally I would prefer to avoid shell as well when it is not really necessary. I am surprised that in the discussion of problem related to desktop integration and perhaps even order in which applications able to handle particular file format were installed, nobody mentioned such details, neither for "positive" nor for "negative" results. Probably output of the following commands (for the proper mime type) could be relevant. The complication is that there are several mime handler "databases". grep image/png /etc/mailcap ~/.mailcap xdg-mime query default image/png (mailcap-parse-mailcaps) (mailcap-mime-info "image/png") For some handlers there might be even a race, sometimes it might work but might fail as well, depending if child could send a message to its server quickly enough. In such case providing of ECM might be a challenge.