Skip to content

Commit

Permalink
umu_run: fix subreaping when command errors
Browse files Browse the repository at this point in the history
- Fixes a bug where descendent processes would fail to be reaped in the case the user forcefully terminates the launcher (e.g., control+c). In the event that subprocess.run raises an error due to any failure in the command execution, it would kill Reaper. Therefore, subprocess.run should always silently fail in this case for reaping to occur and the launcher handle non-zero statuses
  • Loading branch information
R1kaB3rN committed Mar 23, 2024
1 parent 11ca492 commit e0fd609
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions umu/umu_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from typing import Dict, Any, List, Set, Union, Tuple
from umu_plugins import enable_steam_game_drive, set_env_toml, enable_reaper
from re import match
from subprocess import run, CalledProcessError
from subprocess import run
from umu_dl_util import get_umu_proton
from umu_consts import PROTON_VERBS, DEBUG_FORMAT, STEAM_COMPAT, UMU_LOCAL
from umu_util import setup_umu
Expand Down Expand Up @@ -255,7 +255,7 @@ def build_command(
return command


def main() -> None: # noqa: D103
def main() -> int: # noqa: D103
env: Dict[str, str] = {
"WINEPREFIX": "",
"GAMEID": "",
Expand Down Expand Up @@ -350,17 +350,18 @@ def main() -> None: # noqa: D103
build_command(env, UMU_LOCAL, command, opts)
log.debug("%s", command)

return run(command, check=True)
return run(command, check=False).returncode


if __name__ == "__main__":
try:
main()
sys.exit(main())
except KeyboardInterrupt:
log.warning("Keyboard Interrupt")
sys.exit(1)
except CalledProcessError:
log.exception("CalledProcessError")
except SystemExit as e:
if e.code != 0:
raise Exception(e)
except Exception:
log.exception("Exception")
sys.exit(1)
Expand Down

0 comments on commit e0fd609

Please sign in to comment.