2009-01-07 Geoff Norton <gnorton@novell.com>
authorGeoff Norton <grompf@sublimeintervention.com>
Wed, 7 Jan 2009 06:30:43 +0000 (06:30 -0000)
committerGeoff Norton <grompf@sublimeintervention.com>
Wed, 7 Jan 2009 06:30:43 +0000 (06:30 -0000)
        * processes.c: Only use open -W on OSX 10.5+.  Patch from
        Miguel

svn path=/trunk/mono/; revision=122614

mono/io-layer/ChangeLog
mono/io-layer/processes.c

index 05e82a00e10597960fd80069ec861f9a769a9b1f..ec7860707b1e432038c52ed968f9beba91d0d63c 100644 (file)
@@ -1,3 +1,8 @@
+2009-01-07  Geoff Norton  <gnorton@novell.com>
+
+        * processes.c: Only use open -W on OSX 10.5+.  Patch from
+        Miguel
+
 2008-12-19  Bill Holmes  <billholmes54@gmail.com>
 
        * processes.c (get_module_name) : adjust size for unicode characters.
index 014439b02084f3bf4179fcce916614cc79c02b9f..8a0e89d0833342a1cd4f152a396163108045c9bd 100644 (file)
@@ -394,6 +394,55 @@ utf16_concat (const gunichar2 *first, ...)
        return ret;
 }
 
+#ifdef PLATFORM_MACOSX
+#include <sys/utsname.h>
+
+/* 0 = no detection; -1 = not 10.5 or higher;  1 = 10.5 or higher */
+static int detected_osx_version;
+
+static void
+detect_osx_10_5_or_higher ()
+{
+       struct utsname u;
+       char *p;
+       int v;
+       
+       if (uname (&u) != 0){
+               detected_osx_version = 1;
+               return;
+       }
+
+       p = u.release;
+       v = atoi (p);
+       
+       if (v < 9){
+               detected_osx_version = -1;
+       } else if (v > 9)
+               detected_osx_version = 1;
+       else {
+               while (*p && *p != '.')
+                       p++;
+               if (*p == '.'){
+                       p++;
+                       if (atoi (p) > 4){
+                               detected_osx_version = 1;
+                               return;
+                       }
+               }
+               detected_osx_version = -1;
+       }
+}
+
+static gboolean
+is_macos_10_5_or_higher ()
+{
+       if (detected_osx_version == 0)
+               detect_osx_10_5_or_higher ();
+       
+       return detected_osx_version + 1;
+}
+#endif
+
 static const gunichar2 utf16_space_bytes [2] = { 0x20, 0 };
 static const gunichar2 *utf16_space = utf16_space_bytes; 
 static const gunichar2 utf16_quote_bytes [2] = { 0x22, 0 };
@@ -442,7 +491,10 @@ gboolean ShellExecuteEx (WapiShellExecuteInfo *sei)
                        return FALSE;
 
 #ifdef PLATFORM_MACOSX
-               handler = g_strdup ("/usr/bin/open -W");
+               if (is_macos_10_5_or_higher ())
+                       handler = g_strdup ("/usr/bin/open -W");
+               else
+                       handler = g_strdup ("/usr/bin/open");
 #else
                /*
                 * On Linux, try: xdg-open, the FreeDesktop standard way of doing it,