[folks/paging: 2/3] Use GLib.Process instead of just FILE.popen. Parse arguments with GLib.Shell.parse_argv. No longer s
- From: Jeremy Whiting <jpwhiting src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [folks/paging: 2/3] Use GLib.Process instead of just FILE.popen. Parse arguments with GLib.Shell.parse_argv. No longer s
- Date: Tue, 10 Jul 2012 16:49:08 +0000 (UTC)
commit 31e4243f0f48f86ce5c5a9fbf87ee0f962dbdc60
Author: Jeremy Whiting <jpwhiting kde org>
Date: Tue Jul 10 10:46:10 2012 -0600
Use GLib.Process instead of just FILE.popen.
Parse arguments with GLib.Shell.parse_argv.
No longer store FILE object, just file descriptor.
tools/inspect/utils.vala | 34 +++++++++++++++++++++++++++++-----
1 files changed, 29 insertions(+), 5 deletions(-)
---
diff --git a/tools/inspect/utils.vala b/tools/inspect/utils.vala
index 084f8b8..ffd0462 100644
--- a/tools/inspect/utils.vala
+++ b/tools/inspect/utils.vala
@@ -32,7 +32,7 @@ private class Folks.Inspect.Utils
/* To page or not to page? */
private static bool _page_output = false;
private static IOChannel _io_channel;
- private static FILE? _pager;
+ private static int _pager_fd;
public static void init ()
{
@@ -62,12 +62,33 @@ private class Folks.Inspect.Utils
if (pager == null)
pager = "less -FRSX";
+
+ /* Convert command to null terminated array */
+ string[] args;
+ try
+ {
+ GLib.Shell.parse_argv(pager, out args);
+ }
+ catch (GLib.ShellError e)
+ {
+ debug ("Error parsing pager arguments");
+ }
/* In case the previous clean up wasn't finish */
Utils.stop_paged_output ();
- Utils._pager = FILE.popen (pager, "w");
- Utils._io_channel = new IOChannel.unix_new (Utils._pager.fileno ());
+ GLib.Process.spawn_async_with_pipes (null,
+ args,
+ null,
+ GLib.SpawnFlags.LEAVE_DESCRIPTORS_OPEN |
+ GLib.SpawnFlags.SEARCH_PATH,
+ null,
+ null,
+ out Utils._pager_fd, // Std input
+ null, // Std out
+ null); // Std error
+ Utils._io_channel = new IOChannel.unix_new (Utils._pager_fd);
+ Utils._io_channel.set_close_on_unref (true);
Utils._page_output = true;
}
@@ -80,11 +101,14 @@ private class Folks.Inspect.Utils
{
Utils._io_channel.shutdown (true);
}
- catch (GLib.Error e) {}
+ catch (GLib.Error e)
+ {
+ debug ("Error shutting down io channel %s", e.message);
+ }
finally
{
Utils._io_channel = null;
- Utils._pager = null;
+ Utils._pager_fd = 0;
Utils._page_output = false;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]