Skip to content

scripts: Ignore errors when showing diagnostic messages

Simon McVittie requested to merge wip/smcv/failed-log-not-fatal into master

If users of an X11 environment restart it inside a terminal emulator, and then close the terminal emulator (which seems to be a somewhat popular meme on various forums), we can end up with stdout/stderr pointing to a pseudo-terminal that is no longer associated with a terminal emulator. All writes to such a terminal fail, and when we're running under set -e, that will terminate the script. Worse, we can't even diagnose what has happened, because any error messages we might have shown are also going into the void.

Mitigate this by ignoring set -e when logging diagnostic messages, analogous to the behaviour of g_warning() and similar C API calls. (After all, what would we do about it - log a diagnostic message?)

Related to https://github.com/ValveSoftware/steam-for-linux/issues/8069.


It's quite difficult to reproduce the bug here! Here's one way:

Have a desktop environment where Steam has a system tray icon, either an appindicator or a legacy X11 status notifier. In KDE/Plasma this happens by default, in GNOME you'll need a Shell extension.

First, configure a game to use SLR and launch it. This is to get it onto your list of recently-played games.

Get the broken situation: https://github.com/ValveSoftware/steam-for-linux/issues/8069#issuecomment-954081641 (or you could do similar things with plasmashell --replace, or maybe gnome-shell --replace).

ssh in and edit _v2-entry-point so that immediately after parsing options, but before opening the log file, it does this:

logger -t sfl8069 "before calling log"
log "hello, world"
logger -t slf8069 "after calling log"

Launch the game, by right-clicking on Steam's system tray icon and choosing it from there. You can't launch it through the Library because https://github.com/ValveSoftware/steam-for-linux/issues/8069 has broken your steamwebhelper...

The game logs sfl8069[$pid]: before calling log to the Journal, but then stops. sfl8069[$pid]: after calling log is not logged and the game doesn't start.

Repeat, with this change. This time, both log messages appear in the Journal and the game starts.

Merge request reports