gio open exits with success even though the underlying exec failed

Bug #2007621 reported by Mike Lundy
10
This bug affects 2 people
Affects Status Importance Assigned to Milestone
glib2.0 (Ubuntu)
Confirmed
Low
Unassigned

Bug Description

This is a sort of annoyingly complex interaction, so bear with me. The observed problem is that xdg-open does not exit with a non-zero exit code when it fails to open.

```
$ unset DISPLAY
$ xdg-open http://example.com
exo-open: Cannot open display: .
$ echo $?
0
```

It turns out to not exactly be xdg-open's fault, though:
```
$ sh -x $(which xdg-open) http://example.com 2>&1 | tail -n10
+ return 0
+ open_xfce http://example.com
+ exo-open --help
+ gio help open
+ gio open http://example.com
exo-open: Cannot open display: .
+ [ 0 -eq 0 ]
+ exit_success
+ [ 0 -gt 0 ]
+ exit 0
```

So, from this we see that xdg-open uses `exo-open --help` to see if exo-open works, but it fails due to the DISPLAY, so it falls back to gio open. gio open ends up turning around and calling exo-open again, but gio swallows the exit code, so xdg-open thinks it worked.

```
$ exo-open http://example.com
exo-open: Cannot open display: .
$ echo $?
1
$ gio open http://example.com
exo-open: Cannot open display: .
$ echo $?
0
```

Versions:
$ lsb_release -rd
Description: Ubuntu 22.04.1 LTS
Release: 22.04
$ xdg-open --version
xdg-open 1.1.3
$ exo-open --version | head -n1
exo-open 4.16.3
$ gio --version
2.72.4

Specifically:
exo-utils:
  Installed: 4.16.3-1
  Candidate: 4.16.3-1
  Version table:
 *** 4.16.3-1 500
        500 http://us.archive.ubuntu.com/ubuntu jammy/universe amd64 Packages
        100 /var/lib/dpkg/status
libglib2.0-bin:
  Installed: 2.72.4-0ubuntu1
  Candidate: 2.72.4-0ubuntu1
  Version table:
 *** 2.72.4-0ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        100 /var/lib/dpkg/status
     2.72.1-1 500
        500 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
xdg-utils:
  Installed: 1.1.3-4.1ubuntu3~22.04.1
  Candidate: 1.1.3-4.1ubuntu3~22.04.1
  Version table:
 *** 1.1.3-4.1ubuntu3~22.04.1 500
        500 http://us.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu jammy-updates/main i386 Packages
        100 /var/lib/dpkg/status
     1.1.3-4.1ubuntu1 500
        500 http://us.archive.ubuntu.com/ubuntu jammy/main amd64 Packages
        500 http://us.archive.ubuntu.com/ubuntu jammy/main i386 Packages

Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in glib2.0 (Ubuntu):
status: New → Confirmed
Revision history for this message
Sebastien Bacher (seb128) wrote :

Thank you for your bug report. Indeed that seems incorrect and should be reported to https://gitlab.gnome.org/GNOME/glib/-/issues

Changed in glib2.0 (Ubuntu):
importance: Undecided → Low
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.