gio open exits with success even though the underlying exec failed
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://
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://
+ return 0
+ open_xfce http://
+ exo-open --help
+ gio help open
+ gio open http://
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://
exo-open: Cannot open display: .
$ echo $?
1
$ gio open http://
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://
100 /var/lib/
libglib2.0-bin:
Installed: 2.72.4-0ubuntu1
Candidate: 2.72.4-0ubuntu1
Version table:
*** 2.72.4-0ubuntu1 500
500 http://
100 /var/lib/
2.72.1-1 500
500 http://
xdg-utils:
Installed: 1.1.3-4.
Candidate: 1.1.3-4.
Version table:
*** 1.1.3-4.
500 http://
500 http://
100 /var/lib/
1.
500 http://
500 http://
Status changed to 'Confirmed' because the bug affects multiple users.