[sgen] We must do bridge processing with all sgen locks taken.
[mono.git] / mono / metadata / process.c
old mode 100644 (file)
new mode 100755 (executable)
index 5dc231e..0820433
 #include <mono/utils/strenc.h>
 #include <mono/utils/mono-proclib.h>
 #include <mono/io-layer/io-layer.h>
+#if defined (MINGW_CROSS_COMPILE) && defined (HAVE_GETPROCESSID)
+#undef HAVE_GETPROCESSID
+#endif
+#ifndef HAVE_GETPROCESSID
+#if defined(_MSC_VER) || defined(HAVE_WINTERNL_H)
+#include <winternl.h>
+#ifndef NT_SUCCESS
+#define NT_SUCCESS(status) ((NTSTATUS) (status) >= 0)
+#endif /* !NT_SUCCESS */
+#else /* ! (defined(_MSC_VER) || defined(HAVE_WINTERNL_H)) */
+#include <ddk/ntddk.h>
+#include <ddk/ntapi.h>
+#endif /* (defined(_MSC_VER) || defined(HAVE_WINTERNL_H)) */
+#endif /* !HAVE_GETPROCESSID */
 /* FIXME: fix this code to not depend so much on the inetrnals */
 #include <mono/metadata/class-internals.h>
 
@@ -65,7 +79,7 @@ void ves_icall_System_Diagnostics_Process_Process_free_internal (MonoObject *thi
        g_message ("%s: Closing process %p, handle %p", __func__, this, process);
 #endif
 
-#if TARGET_WIN32
+#if defined(TARGET_WIN32) || defined(HOST_WIN32)
        CloseHandle (process);
 #else
        CloseProcess (process);
@@ -514,10 +528,6 @@ complete_path (const gunichar2 *appname, gchar **completed)
        return TRUE;
 }
 
-#if defined (MINGW_CROSS_COMPILE) && defined (HAVE_GETPROCESSID)
-#undef HAVE_GETPROCESSID
-#endif
-
 #ifndef HAVE_GETPROCESSID
 /* Run-time GetProcessId detection for Windows */
 #ifdef TARGET_WIN32
@@ -737,7 +747,7 @@ MonoBoolean ves_icall_System_Diagnostics_Process_CreateProcess_internal (MonoPro
        /* The default dir name is "".  Turn that into NULL to mean
         * "current directory"
         */
-       if(mono_string_length (proc_start_info->working_directory)==0) {
+       if(proc_start_info->working_directory == NULL || mono_string_length (proc_start_info->working_directory)==0) {
                dir=NULL;
        } else {
                dir=mono_string_chars (proc_start_info->working_directory);