[gnome-games] command-runner: Add watch_child construction param
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] command-runner: Add watch_child construction param
- Date: Thu, 12 May 2016 10:19:52 +0000 (UTC)
commit d21db373ececa4f4d6ff4a7bde583de5851d38f0
Author: Adrien Plazas <kekun plazas laposte net>
Date: Thu May 12 12:09:17 2016 +0200
command-runner: Add watch_child construction param
Make CommandRunner monitoring the child process an option.
This will be used in next commit to remove SteamRunner.
plugins/desktop/src/desktop-game.vala | 2 +-
plugins/love/src/love-game.vala | 2 +-
src/command/command-runner.vala | 17 ++++++++++++-----
3 files changed, 14 insertions(+), 7 deletions(-)
---
diff --git a/plugins/desktop/src/desktop-game.vala b/plugins/desktop/src/desktop-game.vala
index 2ae4bb6..9aa8887 100644
--- a/plugins/desktop/src/desktop-game.vala
+++ b/plugins/desktop/src/desktop-game.vala
@@ -29,6 +29,6 @@ private class Games.DesktopGame: Object, Game {
throw new CommandError.INVALID_COMMAND ("Couldn't run '%s': %s".printf (name,
e.message));
}
- return new CommandRunner (args);
+ return new CommandRunner (args, true);
}
}
diff --git a/plugins/love/src/love-game.vala b/plugins/love/src/love-game.vala
index 6b3e833..4b695f8 100644
--- a/plugins/love/src/love-game.vala
+++ b/plugins/love/src/love-game.vala
@@ -37,6 +37,6 @@ private class Games.LoveGame : Object, Game {
public Runner get_runner () throws Error {
string[] args = { "love", path };
- return new CommandRunner (args);
+ return new CommandRunner (args, true);
}
}
diff --git a/src/command/command-runner.vala b/src/command/command-runner.vala
index 15fc398..353f4f3 100644
--- a/src/command/command-runner.vala
+++ b/src/command/command-runner.vala
@@ -10,9 +10,11 @@ public class Games.CommandRunner : Object, Runner {
}
private string[] args;
+ private bool watch_child;
- public CommandRunner (string[] args) {
+ public CommandRunner (string[] args, bool watch_child) {
this.args = args;
+ this.watch_child = watch_child;
}
public void check_is_valid () throws Error {
@@ -27,13 +29,14 @@ public class Games.CommandRunner : Object, Runner {
private bool running;
public void start () throws Error {
- if (running)
+ if (running && watch_child)
return;
string? working_directory = null;
string[]? envp = null;
- var flags = SpawnFlags.SEARCH_PATH |
- SpawnFlags.DO_NOT_REAP_CHILD; // Necessary to watch the child ourselves.
+ 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;
@@ -50,9 +53,13 @@ public class Games.CommandRunner : Object, Runner {
catch (SpawnError e) {
warning ("%s\n", e.message);
- return;
+ if (watch_child)
+ return;
}
+ if (!watch_child)
+ return;
+
ChildWatch.add (pid, (() => { on_process_stopped (); }));
running = true;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]