[gnome-boxes] util: teach exec to optionally return stdout and stderr
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-boxes] util: teach exec to optionally return stdout and stderr
- Date: Tue, 7 Aug 2012 17:19:49 +0000 (UTC)
commit a894d5059f2a658c1c5fff4cbd95cbb9f7b6f209
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date: Fri Aug 3 14:39:48 2012 +0200
util: teach exec to optionally return stdout and stderr
https://bugzilla.gnome.org/show_bug.cgi?id=681132
src/util.vala | 26 ++++++++++++++++++++------
1 files changed, 20 insertions(+), 6 deletions(-)
---
diff --git a/src/util.vala b/src/util.vala
index 52d2bb5..a59c8ed 100644
--- a/src/util.vala
+++ b/src/util.vala
@@ -463,13 +463,26 @@ namespace Boxes {
throw e;
}
- public async void exec (string[] argv, Cancellable? cancellable) throws GLib.Error {
+ public async void exec (string[] argv,
+ Cancellable? cancellable,
+ out string? standard_output = null,
+ out string? standard_error = null) throws GLib.Error {
+
+ // FIXME: https://bugzilla.gnome.org/show_bug.cgi?id=681136
+ string std_output = "";
+ string std_error = "";
+
yield run_in_thread (() => {
- exec_sync (argv);
- });
+ exec_sync (argv, out std_output, out std_error);
+ }, cancellable);
+
+ standard_output = std_output;
+ standard_error = std_error;
}
- public void exec_sync (string[] argv) throws GLib.Error {
+ public void exec_sync (string[] argv,
+ out string? standard_output = null,
+ out string? standard_error = null) throws GLib.Error {
int exit_status = -1;
Process.spawn_sync (null,
@@ -477,9 +490,10 @@ namespace Boxes {
null,
SpawnFlags.SEARCH_PATH,
null,
- null,
- null,
+ out standard_output,
+ out standard_error,
out exit_status);
+
if (exit_status != 0)
throw new Boxes.Error.COMMAND_FAILED ("Failed to execute: %s", string.joinv (" ", argv));
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]