From c19bede0d707540704beb43b63e7a765a287df18 Mon Sep 17 00:00:00 2001 From: Bastien Nocera Date: Fri, 26 Jan 2024 12:06:40 +0100 Subject: [PATCH] main: Return return code from launched executable Using powerprofilesctl to launch an app would always result in what was detected as success, because the code wasn't propagating the retval from the launched application. --- src/powerprofilesctl.in | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/powerprofilesctl.in b/src/powerprofilesctl.in index 6197709..59b9fb3 100755 --- a/src/powerprofilesctl.in +++ b/src/powerprofilesctl.in @@ -170,6 +170,7 @@ def _list_holds(): index += 1 def _launch(args, profile, appid, reason): + ret = 0 try: bus = Gio.bus_get_sync(Gio.BusType.SYSTEM, None) proxy = Gio.DBusProxy.new_sync(bus, Gio.DBusProxyFlags.NONE, None, @@ -189,8 +190,11 @@ def _launch(args, profile, appid, reason): # print (f'Got {cookie} for {profile} hold') with subprocess.Popen(args) as launched_app: launched_app.wait() + ret = launched_app.returncode proxy.ReleaseProfile('(u)', cookie) + return ret + def main(): # pylint: disable=too-many-branches, disable=too-many-statements args = None if len(sys.argv) == 1: @@ -277,7 +281,8 @@ def main(): # pylint: disable=too-many-branches, disable=too-many-statements if not profile: profile = 'performance' try: - _launch(args, profile, appid, reason) + ret = _launch(args, profile, appid, reason) + sys.exit(ret) except GLib.Error as error: sys.stderr.write(f'Failed to communicate with power-profiles-daemon: {format(error)}\n') sys.exit(1)