Index: libs/libmyth/mythcontext.cpp
===================================================================
--- libs/libmyth/mythcontext.cpp	(revision 20658)
+++ libs/libmyth/mythcontext.cpp	(working copy)
@@ -1547,6 +1547,8 @@
 {
 #if defined(CONFIG_DARWIN) || (__FreeBSD__) || defined(__OpenBSD__)
     const char *command = "ps -ax | grep -i mythbackend | grep -v grep > /dev/null";
+#elif defined USING_MINGW
+    const char *command = "tasklist | find /i \"mythbackend.exe\" ";
 #else
     const char *command = "ps -ae | grep mythbackend > /dev/null";
 #endif
Index: libs/libmyth/util.cpp
===================================================================
--- libs/libmyth/util.cpp	(revision 20658)
+++ libs/libmyth/util.cpp	(working copy)
@@ -1118,7 +1118,11 @@
     if (GetTempFileNameA(temppath, "mth", 0, tempfilename))
     {
         if (dir)
+        {
+            // GetTempFileNameA creates the file, so delete it before mkdir
+            unlink(tempfilename);
             ret = mkdir(tempfilename);
+        }
         else
             ret = open(tempfilename, O_CREAT | O_RDWR, S_IREAD | S_IWRITE);
     }
Index: libs/libmythui/mythsystem.cpp
===================================================================
--- libs/libmythui/mythsystem.cpp	(revision 20658)
+++ libs/libmythui/mythsystem.cpp	(working copy)
@@ -178,9 +178,15 @@
             VERBOSE(VB_IMPORTANT,
                     (LOC_ERR + "WaitForSingleObject() failed because %1")
                     .arg(::GetLastError()));
+        DWORD exitcode = GENERIC_EXIT_OK;
+        if (!GetExitCodeProcess(pi.hProcess, &exitcode))
+            VERBOSE(VB_IMPORTANT, (LOC_ERR + 
+                    "GetExitCodeProcess() failed because %1")
+                    .arg(::GetLastError()));
         CloseHandle(pi.hProcess);
         CloseHandle(pi.hThread);
-        return GENERIC_EXIT_OK;
+        // VERBOSE(VB_IMPORTANT, cmd + QString(" returned %1").arg(exitcode));
+        return exitcode;
     }
 #endif
     return GENERIC_EXIT_NOT_OK;
Index: libs/libmythtv/ThreadedFileWriter.cpp
===================================================================
--- libs/libmythtv/ThreadedFileWriter.cpp	(revision 20658)
+++ libs/libmythtv/ThreadedFileWriter.cpp	(working copy)
@@ -161,6 +161,9 @@
     }
     else
     {
+#ifdef USING_MINGW
+        _setmode(fd, _O_BINARY);
+#endif
         buf = new char[TFW_DEF_BUF_SIZE + 1024];
         bzero(buf, TFW_DEF_BUF_SIZE + 64);
 
