From 5b706faa731ee073968dfa1d7b1f73375438c608 Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Tue, 21 Jul 2020 16:55:57 +0200 Subject: [PATCH] open: Workaround an xdg-open bug If it can't recognize the DE, xdg-open uses a "generic" way of opening things where it doesn't spawn off a DE-provided utility like kde-open. This sounds great, but it fails to fork and therefore blocks the terminal. So we start it in the background and disown it. Fixes #7215. --- share/functions/open.fish | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/share/functions/open.fish b/share/functions/open.fish index e14bce183..565bd8496 100644 --- a/share/functions/open.fish +++ b/share/functions/open.fish @@ -24,7 +24,14 @@ if not command -sq open end else if type -q -f xdg-open for i in $argv - xdg-open $i + # In the "generic" path where it doesn't use a helper utility, + # xdg-open fails to fork off, so it blocks the terminal. + xdg-open $i & + # Note: We *need* to pass $last_pid, or it will disown the last *existing* job. + # In case xdg-open forks, that would be whatever else the user has backgrounded. + # + # Yes, this has a (hopefully theoretical) race of the PID being recycled. + disown $last_pid 2>/dev/null end else echo (_ 'No open utility found. Try installing "xdg-open" or "xdg-utils".')