Fix warnings in eglib gspawn.c on platforms lacking fork/execv. (mono/mono#16801)
authorJohan Lorensson <lateralusx.github@gmail.com>
Mon, 16 Sep 2019 21:19:00 +0000 (23:19 +0200)
committerZoltan Varga <vargaz@gmail.com>
Mon, 16 Sep 2019 21:18:59 +0000 (17:18 -0400)
Commit migrated from https://github.com/mono/mono/commit/e8570d950075153de81ab49410109ed7c7b4688f

src/mono/mono/eglib/gspawn.c

index 9be865a..64ac161 100644 (file)
@@ -96,7 +96,7 @@ extern char **environ;
 G_END_DECLS
 #endif
 
-#ifndef G_OS_WIN32
+#if !defined (G_OS_WIN32) && defined (HAVE_FORK) && defined (HAVE_EXECV)
 static int
 safe_read (int fd, gchar *buffer, gint count, GError **gerror)
 {
@@ -135,21 +135,12 @@ read_pipes (int outfd, gchar **out_str, int errfd, gchar **err_str, GError **ger
                if (out_closed && err_closed)
                        break;
 
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4389)
-#endif
-
                FD_ZERO (&rfds);
                if (!out_closed && outfd >= 0)
                        FD_SET (outfd, &rfds);
                if (!err_closed && errfd >= 0)
                        FD_SET (errfd, &rfds);
 
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
                res = select (MAX (outfd, errfd) + 1, &rfds, NULL, NULL, NULL);
                if (res > 0) {
                        if (buffer == NULL)
@@ -203,7 +194,6 @@ create_pipe (int *fds, GError **gerror)
        }
        return TRUE;
 }
-#endif /* G_OS_WIN32 */
 
 static int
 write_all (int fd, const void *vbuf, size_t n)
@@ -225,6 +215,7 @@ write_all (int fd, const void *vbuf, size_t n)
        
        return nwritten;
 }
+#endif /* !defined (G_OS_WIN32) && defined (HAVE_FORK) && defined (HAVE_EXECV) */
 
 #if !defined(G_OS_WIN32) && defined(HAVE_GETDTABLESIZE)
 int
@@ -257,6 +248,7 @@ g_spawn_command_line_sync (const gchar *command_line,
                                GError **gerror)
 {
 #ifdef G_OS_WIN32
+       return TRUE;
 #elif !defined (HAVE_FORK) || !defined (HAVE_EXECV)
        fprintf (stderr, "g_spawn_command_line_sync not supported on this platform\n");
        return FALSE;
@@ -334,8 +326,8 @@ g_spawn_command_line_sync (const gchar *command_line,
        if (WIFEXITED (status) && exit_status) {
                *exit_status = WEXITSTATUS (status);
        }
-#endif
        return TRUE;
+#endif
 }
 
 /*
@@ -356,6 +348,7 @@ g_spawn_async_with_pipes (const gchar *working_directory,
                        GError **gerror)
 {
 #ifdef G_OS_WIN32
+       return TRUE;
 #elif !defined (HAVE_FORK) || !defined (HAVE_EXECVE)
        fprintf (stderr, "g_spawn_async_with_pipes is not supported on this platform\n");
        return FALSE;
@@ -528,8 +521,6 @@ g_spawn_async_with_pipes (const gchar *working_directory,
                *standard_output = out_pipe [0];
        if (standard_error)
                *standard_error = err_pipe [0];
-#endif
        return TRUE;
+#endif
 }
-
-