[gnome-games] command: Remove process watching



commit 1c3ed1022d834df430beb29034fb78d046828c12
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Thu Aug 16 13:42:22 2018 +0500

    command: Remove process watching
    
    It's not used for anything, doesn't work with Steam and wouldn't work with
    'flatpak-spawn', so just remove it.

 plugins/desktop/src/desktop-plugin.vala |  2 +-
 plugins/love/src/love-plugin.vala       |  2 +-
 plugins/steam/src/steam-plugin.vala     |  2 +-
 src/command/command-runner.vala         | 34 +++------------------------------
 4 files changed, 6 insertions(+), 34 deletions(-)
---
diff --git a/plugins/desktop/src/desktop-plugin.vala b/plugins/desktop/src/desktop-plugin.vala
index f83c29b4..0a8781c4 100644
--- a/plugins/desktop/src/desktop-plugin.vala
+++ b/plugins/desktop/src/desktop-plugin.vala
@@ -54,7 +54,7 @@ private class Games.DesktopPlugin : Object, Plugin {
                var command = app_info.get_commandline ();
                if (!Shell.parse_argv (command, out args))
                        throw new CommandError.INVALID_COMMAND (_("Invalid command “%s”."), command);
-               var runner = new CommandRunner (args, true);
+               var runner = new CommandRunner (args);
 
                var game = new GenericGame (uid, title, platform, runner);
                game.set_icon (icon);
diff --git a/plugins/love/src/love-plugin.vala b/plugins/love/src/love-plugin.vala
index 9cc26de3..8eea7327 100644
--- a/plugins/love/src/love-plugin.vala
+++ b/plugins/love/src/love-plugin.vala
@@ -31,7 +31,7 @@ private class Games.LovePlugin : Object, Plugin {
                var icon = new LoveIcon (package);
                var cover = new LocalCover (uri);
                string[] args = { "love", uri.to_string () };
-               var runner = new CommandRunner (args, true);
+               var runner = new CommandRunner (args);
 
                var game = new GenericGame (uid, title, platform, runner);
                game.set_icon (icon);
diff --git a/plugins/steam/src/steam-plugin.vala b/plugins/steam/src/steam-plugin.vala
index 07b1a10c..1bf78efe 100644
--- a/plugins/steam/src/steam-plugin.vala
+++ b/plugins/steam/src/steam-plugin.vala
@@ -88,7 +88,7 @@ private class Games.SteamPlugin : Object, Plugin {
                foreach (var part in command)
                        args += part;
                args += @"steam://rungameid/$game_id";
-               var runner = new CommandRunner (args, false);
+               var runner = new CommandRunner (args);
 
                var game = new GenericGame (uid, title, platform, runner);
                game.set_icon (icon);
diff --git a/src/command/command-runner.vala b/src/command/command-runner.vala
index 92b0b35f..2321e0b1 100644
--- a/src/command/command-runner.vala
+++ b/src/command/command-runner.vala
@@ -18,11 +18,9 @@ public class Games.CommandRunner : Object, Runner {
        }
 
        private string[] args;
-       private bool watch_child;
 
-       public CommandRunner (string[] args, bool watch_child) {
+       public CommandRunner (string[] args) {
                this.args = args;
-               this.watch_child = watch_child;
        }
 
        public bool check_is_valid (out string error_message) throws Error {
@@ -42,43 +40,22 @@ public class Games.CommandRunner : Object, Runner {
                return new RemoteDisplay ();
        }
 
-       private bool running;
-
        public void start () throws Error {
-               if (running && watch_child)
-                       return;
-
                string? working_directory = null;
                string[]? envp = null;
                var flags = SpawnFlags.SEARCH_PATH;
-               if (watch_child)
-                       flags |= SpawnFlags.DO_NOT_REAP_CHILD; // Necessary to watch the child ourselves.
                SpawnChildSetupFunc? child_setup = null;
                Pid pid;
-               int? standard_input = null;
-               int? standard_output = null;
-               int? standard_error = null;
 
                try {
-                       var result = Process.spawn_async_with_pipes (
-                               working_directory, args, envp, flags, child_setup, out pid,
-                               out standard_input, out standard_output, out standard_error);
+                       var result = Process.spawn_async (
+                               working_directory, args, envp, flags, child_setup, out pid);
                        if (!result)
                                throw new CommandError.EXECUTION_FAILED (_("Couldn’t run “%s”: execution 
failed."), args[0]);
                }
                catch (SpawnError e) {
                        warning ("%s\n", e.message);
-
-                       if (watch_child)
-                               return;
                }
-
-               if (!watch_child)
-                       return;
-
-               ChildWatch.add (pid, (() => { on_process_stopped (); }));
-
-               running = true;
        }
 
        public void resume () throws Error {
@@ -89,9 +66,4 @@ public class Games.CommandRunner : Object, Runner {
 
        public void stop () {
        }
-
-       private void on_process_stopped () {
-               running = false;
-               stopped ();
-       }
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]