Seeker14491 / opener

Open a file or link in the system default program.
Apache License 2.0
54 stars 11 forks source link

Make linux check for subprocess errors #14

Closed apgoetz closed 1 year ago

apgoetz commented 1 year ago

MacOS, Windows and WSL wait for the open child process to exit, and checks its exit code. This means that errors in the opening process are returned to the user. However, the linux implementation does not wait for the xdg-open process to exit. This means that potential errors returned by xdg-open are ignored.

This fixes the code by making the linux implementation also wait for the child process to exit, and checking its return type.

Seeker14491 commented 1 year ago

The current behavior is deliberate. While it would be nice to be able to catch errors in this situation, if we catch errors by waiting for xdg-open to finish, we run into the issue of xdg-open, in certain cases, blocking until the launched application exits, which we don't want.

apgoetz commented 1 year ago

Thanks for explaining.

I guess I was confused since I saw the MacOS and WSL implementations waiting for their opener programs to exit, but it makes sense that their behavior is much more strongly specified than a generic xdg-open's behavior.

Would you be interested in other ways to align the behavior of the linux implementation with Windows/MacOS? For example, if there was a way to force the use of the embedded xdg-open it might be possible to make stronger guarantees about it exiting since the script is vendored in this crate.

Seeker14491 commented 1 year ago

The reasoning for the current behavior of trying the system xdg-open first is that some users (and distros?) use a customized xdg-open, or even an entirely different binary/script aliased as xdg-open that the user expects to handle the opening. We shouldn't break that. I don't know if there's a way to improve the situation given these constraints.

apgoetz commented 1 year ago

No worries, thanks for the explanation