[gnome-calculator/gnome-3-14] search-provider: discard stdout/stderr



commit 0f0713a963906b4e9579866d089d6d677674edbe
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Sun May 10 17:52:46 2015 -0500

    search-provider: discard stdout/stderr
    
    When we pass input to gnome-calculator, it uses stderr to report invalid
    input. But we expect most everything that we pass to be invalid, since
    this is a search provider, so this needs to be suppressed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=745751

 search-provider/search-provider.vala |   12 +++++++++---
 1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/search-provider/search-provider.vala b/search-provider/search-provider.vala
index eca8d77..92ff1fa 100644
--- a/search-provider/search-provider.vala
+++ b/search-provider/search-provider.vala
@@ -39,9 +39,13 @@ public class SearchProvider : Object
                 return false;
             }
 
+            // Eat output so that it doesn't wind up in the journal. It's
+            // expected that most searches are not valid calculator input.
+            string stdout_buf;
+            string stderr_buf;
             Process.spawn_command_line_sync (
                 "gnome-calculator --solve " + Shell.quote (equation),
-                null, null, out exit_status);
+                out stdout_buf, out stderr_buf, out exit_status);
             Process.check_exit_status (exit_status);
         }
         catch (SpawnError e)
@@ -82,6 +86,7 @@ public class SearchProvider : Object
     {
         Subprocess subprocess;
         string stdout_buf;
+        string stderr_buf;
 
         string[] argv = {"gnome-calculator", "--solve"};
         argv += results[0];
@@ -89,7 +94,7 @@ public class SearchProvider : Object
 
         try
         {
-            subprocess = new Subprocess.newv (argv, SubprocessFlags.STDOUT_PIPE);
+            subprocess = new Subprocess.newv (argv, SubprocessFlags.STDOUT_PIPE | 
SubprocessFlags.STDERR_PIPE);
         }
         catch (Error e)
         {
@@ -98,7 +103,8 @@ public class SearchProvider : Object
 
         try
         {
-            subprocess.communicate_utf8 (null, null, out stdout_buf, null);
+            subprocess.communicate_utf8 (null, null, out stdout_buf, out stderr_buf);
+            assert (stderr_buf == "");
         }
         catch (Error e)
         {


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