Author: dbera
Date: Sun Feb 10 21:16:38 2008
New Revision: 4471
URL: http://svn.gnome.org/viewvc/beagle?rev=4471&view=rev

Log:
Use LANG=C for external programs used in filters. Fixes 509487.


Modified:
   trunk/beagle/Filters/FilterDOC.cs
   trunk/beagle/Filters/FilterDeb.cs
   trunk/beagle/Filters/FilterExternal.cs
   trunk/beagle/Filters/FilterMPlayerVideo.cs
   trunk/beagle/Filters/FilterPdf.cs
   trunk/beagle/Filters/FilterRPM.cs
   trunk/beagle/Filters/FilterSpreadsheet.cs
   trunk/beagle/Filters/FilterTotem.cs
   trunk/beagle/Util/SafeProcess.cs
   trunk/beagle/glue/spawn-glue.c

Modified: trunk/beagle/Filters/FilterDOC.cs
==============================================================================
--- trunk/beagle/Filters/FilterDOC.cs   (original)
+++ trunk/beagle/Filters/FilterDOC.cs   Sun Feb 10 21:16:38 2008
@@ -101,6 +101,7 @@
                        pc.Arguments = new string [] { exe, FileInfo.FullName };
                        pc.RedirectStandardOutput = true;
                        pc.RedirectStandardError = true;
+                       pc.UseLangC = true;
 
                        // Let beagle-doc-extractor run for 90 CPU seconds, max.
                        pc.CpuLimit = 90;

Modified: trunk/beagle/Filters/FilterDeb.cs
==============================================================================
--- trunk/beagle/Filters/FilterDeb.cs   (original)
+++ trunk/beagle/Filters/FilterDeb.cs   Sun Feb 10 21:16:38 2008
@@ -48,6 +48,7 @@
                        SafeProcess pc = new SafeProcess ();
                        pc.Arguments = new string [] { "dpkg-deb", "-I", 
FileInfo.FullName};
                        pc.RedirectStandardOutput = true;
+                       pc.UseLangC = true;
                        
                        try {
                                pc.Start ();

Modified: trunk/beagle/Filters/FilterExternal.cs
==============================================================================
--- trunk/beagle/Filters/FilterExternal.cs      (original)
+++ trunk/beagle/Filters/FilterExternal.cs      Sun Feb 10 21:16:38 2008
@@ -181,6 +181,7 @@
                        SafeProcess pc = new SafeProcess ();
                        pc.Arguments = argv;
                        pc.RedirectStandardOutput = true;
+                       pc.UseLangC = true;
 
                        // Let the external filter run for 2 minutes, max.
                        pc.CpuLimit = 120;

Modified: trunk/beagle/Filters/FilterMPlayerVideo.cs
==============================================================================
--- trunk/beagle/Filters/FilterMPlayerVideo.cs  (original)
+++ trunk/beagle/Filters/FilterMPlayerVideo.cs  Sun Feb 10 21:16:38 2008
@@ -122,6 +122,7 @@
                        pc.Arguments = new string [] { "mplayer", "-vo", 
"null", "-ao", "null", "-frames", "0", "-identify", FileInfo.FullName };
                        pc.RedirectStandardOutput = true;
                        pc.RedirectStandardError = true;
+                       pc.UseLangC = true;
 
                        // Let mplayer run for 10 seconds, max.
                        pc.CpuLimit = 10;

Modified: trunk/beagle/Filters/FilterPdf.cs
==============================================================================
--- trunk/beagle/Filters/FilterPdf.cs   (original)
+++ trunk/beagle/Filters/FilterPdf.cs   Sun Feb 10 21:16:38 2008
@@ -50,6 +50,7 @@
                        // use more than 100 megs memory.
                        pc.CpuLimit = 90;
                        pc.MemLimit = 100*1024*1024;
+                       pc.UseLangC = true;
 
                        try {
                                pc.Start ();

Modified: trunk/beagle/Filters/FilterRPM.cs
==============================================================================
--- trunk/beagle/Filters/FilterRPM.cs   (original)
+++ trunk/beagle/Filters/FilterRPM.cs   Sun Feb 10 21:16:38 2008
@@ -63,6 +63,7 @@
                        SafeProcess pc = new SafeProcess ();
                        pc.Arguments = new string [] { "rpm", "-qp", 
"--queryformat", property_queryformat, FileInfo.FullName };
                        pc.RedirectStandardOutput = true;
+                       pc.UseLangC = true;
 
                        // Let rpm run for 15 seconds for properties, max.
                        pc.CpuLimit = 15;

Modified: trunk/beagle/Filters/FilterSpreadsheet.cs
==============================================================================
--- trunk/beagle/Filters/FilterSpreadsheet.cs   (original)
+++ trunk/beagle/Filters/FilterSpreadsheet.cs   Sun Feb 10 21:16:38 2008
@@ -83,6 +83,7 @@
                        SafeProcess pc = new SafeProcess ();
                        pc.Arguments = new string [] { "ssindex", "-i", 
FileInfo.FullName };
                        pc.RedirectStandardOutput = true;
+                       pc.UseLangC = true;
 
                        // Let ssindex run for 10 seconds, max.
                        pc.CpuLimit = 10;

Modified: trunk/beagle/Filters/FilterTotem.cs
==============================================================================
--- trunk/beagle/Filters/FilterTotem.cs (original)
+++ trunk/beagle/Filters/FilterTotem.cs Sun Feb 10 21:16:38 2008
@@ -60,6 +60,7 @@
                        pc.Arguments = new string [] { "totem-video-indexer", 
"--mimetype" };
                        pc.RedirectStandardOutput = true;
                        pc.RedirectStandardError = true;
+                       pc.UseLangC = true;
 
                        try {
                                pc.Start ();

Modified: trunk/beagle/Util/SafeProcess.cs
==============================================================================
--- trunk/beagle/Util/SafeProcess.cs    (original)
+++ trunk/beagle/Util/SafeProcess.cs    Sun Feb 10 21:16:38 2008
@@ -26,6 +26,7 @@
 
 using System;
 using System.IO;
+using System.Collections;
 using System.Runtime.InteropServices;
 using Mono.Unix;
 using GLib;
@@ -39,6 +40,7 @@
                private UnixStream stdin_stream, stdout_stream, stderr_stream;
                private int pid;
                private int cpu_limit, mem_limit;
+               private bool use_lang_c = false;
 
                public string[] Arguments {
                        get { return args; }
@@ -86,8 +88,14 @@
                        set { mem_limit = value; }
                }
 
+               public bool UseLangC {
+                       get { return use_lang_c; }
+                       set { use_lang_c = value; }
+               }
+
                [DllImport ("libbeagleglue")]
                static extern void spawn_async_with_pipes_and_limits (string[] 
argv,
+                                                                     string[] 
env,
                                                                      int 
cpu_limit,
                                                                      int 
mem_limit,
                                                                      out int 
pid,
@@ -110,6 +118,23 @@
                                args = tmp_args;
                        }
 
+                       // If LANG=C needs to be specified, then
+                       // copy the parents environment variable
+                       // and appand LANG=C to it.
+                       // Make sure to null-terminate the env array.
+                       string[] env = null;
+                       if (use_lang_c) {
+                               IDictionary env_dict = 
Environment.GetEnvironmentVariables ();
+                               env = new string [env_dict.Count + 2];
+                               int count = 0;
+                               foreach (DictionaryEntry entry in env_dict)
+                                       if (entry.Key != "LANG")
+                                               env [count ++] = String.Concat 
(entry.Key, "=", entry.Value);
+
+                               env [count ++] = "LANG=C";
+                               env [count] = null;
+                       }
+
                        IntPtr in_ptr = IntPtr.Zero, out_ptr = IntPtr.Zero, 
err_ptr = IntPtr.Zero;
 
                        try {
@@ -123,6 +148,7 @@
                                        err_ptr = Marshal.AllocHGlobal 
(IntPtr.Size);
 
                                spawn_async_with_pipes_and_limits (args,
+                                                                  env,
                                                                   cpu_limit,
                                                                   mem_limit,
                                                                   out pid,
@@ -179,4 +205,4 @@
                internal SafeProcessException (GException gexception) : base 
(gexception.Message) { }
        }
                        
-}
\ No newline at end of file
+}

Modified: trunk/beagle/glue/spawn-glue.c
==============================================================================
--- trunk/beagle/glue/spawn-glue.c      (original)
+++ trunk/beagle/glue/spawn-glue.c      Sun Feb 10 21:16:38 2008
@@ -54,6 +54,7 @@
 
 void
 spawn_async_with_pipes_and_limits (char   **argv,
+                                  char   **envp,
                                   int      cpu_limit,
                                   int      mem_limit,
                                   GPid    *child_pid,
@@ -77,7 +78,7 @@
 
        g_spawn_async_with_pipes (NULL,
                                  argv,
-                                 NULL,
+                                 envp,
                                  flag,
                                  limit_setup_func,
                                  &info,
_______________________________________________
SVN-commits-list mailing list (read only)
http://mail.gnome.org/mailman/listinfo/svn-commits-list

Want to limit the commits to a few modules? Go to above URL, log in to edit 
your options and select the modules ('topics') you want.
Module maintainer? It is possible to set the reply-to to your development 
mailing list. Email [EMAIL PROTECTED] if interested.

Reply via email to