diff --git a/src/Managers/Process.vala b/src/Managers/Process.vala index 200ca009..b59db33b 100644 --- a/src/Managers/Process.vala +++ b/src/Managers/Process.vala @@ -100,7 +100,12 @@ public class Monitor.Process : GLib.Object { var process_provider = ProcessProvider.get_default (); string ? status = process_provider.pids_status.get (this.stat.pid); var status_line = status.split ("\n"); - return int.parse (status_line[8].split ("\t")[1]); + + int uid = int.parse (status_line[8].split ("\t")[1]); + + // @TODO parse users file instead + if (uid == 0) username = "root"; + return uid; } GTop.ProcUid proc_uid; @@ -123,6 +128,15 @@ public class Monitor.Process : GLib.Object { // Kills the process public bool kill () { + if (ProcessUtils.is_flatpak_env ()) { + try { + DBusWorkaroundClient.get_default ().interface.kill_process (this.stat.pid); + return true; + } catch (Error e) { + warning (e.message); + } + } + // Sends a kill signal that cannot be ignored if (Posix.kill (stat.pid, Posix.Signal.KILL) == 0) { return true; @@ -135,6 +149,7 @@ public class Monitor.Process : GLib.Object { if (ProcessUtils.is_flatpak_env ()) { try { DBusWorkaroundClient.get_default ().interface.end_process (this.stat.pid); + return true; } catch (Error e) { warning (e.message); } diff --git a/src/Services/DBusWorkaroundClient.vala b/src/Services/DBusWorkaroundClient.vala index e2e6e276..46e01be7 100644 --- a/src/Services/DBusWorkaroundClient.vala +++ b/src/Services/DBusWorkaroundClient.vala @@ -2,6 +2,7 @@ public interface Monitor.DBusWorkaroundClientInterface : Object { public abstract HashTable[] get_processes (string empty) throws Error; public abstract void end_process (int pid) throws Error; + public abstract void kill_process (int pid) throws Error; } @@ -13,9 +14,6 @@ public class Monitor.DBusWorkaroundClient : Object { return instance.once (() => { return new DBusWorkaroundClient (); }); } - public signal void monitor_vanished (); - public signal void monitor_appeared (); - construct { try { interface = Bus.get_proxy_sync ( @@ -27,9 +25,7 @@ public class Monitor.DBusWorkaroundClient : Object { Bus.watch_name ( BusType.SESSION, "com.github.stsdc.monitor.workaround", - BusNameWatcherFlags.NONE, - () => monitor_appeared (), - () => monitor_vanished () + BusNameWatcherFlags.NONE ); } catch (IOError e) { error ("Monitor Indicator DBus: %s\n", e.message);