OSDN Git Service

fix stderr redirection on mingw. dup2 function doesn't work as it should so must
authorjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 23 May 2010 16:26:02 +0000 (16:26 +0000)
committerjstebbins <jstebbins@b64f7644-9d1e-0410-96f1-a4d463321fa5>
Sun, 23 May 2010 16:26:02 +0000 (16:26 +0000)
reach inside stderr struct and modify _file member directly

git-svn-id: svn://localhost/HandBrake/trunk@3318 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/main.c
libhb/hb.c

index 20e9f85..c26966d 100644 (file)
@@ -658,7 +658,12 @@ IoRedirect(signal_user_data_t *ud)
        // Set encoding to raw.
        g_io_channel_set_encoding (ud->activity_log, NULL, NULL);
        // redirect stderr to the writer end of the pipe
+#if defined(_WIN32)
+       // dup2 doesn't work on windows for some stupid reason
+       stderr->_file = pfd[1];
+#else
        dup2(pfd[1], /*stderr*/2);
+#endif
        setvbuf(stderr, NULL, _IONBF, 0);
        channel = g_io_channel_unix_new (pfd[0]);
        // I was getting an this error:
index 9b16313..001c74c 100644 (file)
@@ -1750,7 +1750,12 @@ static void redirect_thread_func(void * _data)
 {
     int pfd[2];
     pipe(pfd);
+#if defined( SYS_MINGW )
+    // dup2 doesn't work on windows for some stupid reason
+    stderr->_file = pfd[1];
+#else
     dup2(pfd[1], /*stderr*/ 2);
+#endif
     FILE * log_f = fdopen(pfd[0], "rb");
     
     char line_buffer[500];