From 427d42aa515018a12324845916d1ecd036e948dc Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Fri, 7 Aug 2015 10:47:00 +0200 Subject: [PATCH] Add a conditional for fork and exec* functions. They're not available on WatchOS. --- configure.ac | 1 + eglib/configure.ac | 1 + eglib/src/gspawn.c | 6 ++++++ mono/io-layer/processes.c | 5 +++++ mono/mini/mini-darwin.c | 8 ++++++++ 5 files changed, 21 insertions(+) diff --git a/configure.ac b/configure.ac index 9154acf44e7..a04adcdef81 100644 --- a/configure.ac +++ b/configure.ac @@ -2071,6 +2071,7 @@ if test x$host_win32 = xno; then AC_CHECK_FUNCS(readv writev preadv pwritev) AC_CHECK_FUNCS(setpgid) AC_CHECK_FUNCS(system) + AC_CHECK_FUNCS(fork execve) AC_CHECK_SIZEOF(size_t) AC_CHECK_TYPES([blksize_t], [AC_DEFINE(HAVE_BLKSIZE_T)], , [#include diff --git a/eglib/configure.ac b/eglib/configure.ac index f86ae9ff6bc..9d094ea7cdf 100644 --- a/eglib/configure.ac +++ b/eglib/configure.ac @@ -136,6 +136,7 @@ AC_CHECK_SIZEOF(long) AC_CHECK_SIZEOF(long long) AC_CHECK_FUNCS(strlcpy stpcpy strtok_r rewinddir vasprintf) AC_CHECK_FUNCS(getrlimit) +AC_CHECK_FUNCS(fork execv execve) # # Mono currently supports 10.6, but strndup is not available prior to 10.7; avoiding diff --git a/eglib/src/gspawn.c b/eglib/src/gspawn.c index a01904e3e34..4d0bf9e8eca 100644 --- a/eglib/src/gspawn.c +++ b/eglib/src/gspawn.c @@ -248,6 +248,9 @@ g_spawn_command_line_sync (const gchar *command_line, GError **error) { #ifdef G_OS_WIN32 +#elif !defined (HAVE_FORK) || !defined (HAVE_EXECV) + fprintf (stderr, "g_spawn_command_line_sync not supported on this platform\n"); + return FALSE; #else pid_t pid; gchar **argv; @@ -344,6 +347,9 @@ g_spawn_async_with_pipes (const gchar *working_directory, GError **error) { #ifdef G_OS_WIN32 +#elif !defined (HAVE_FORK) || !defined (HAVE_EXECVE) + fprintf (stderr, "g_spawn_async_with_pipes is not supported on this platform\n"); + return FALSE; #else pid_t pid; int info_pipe [2]; diff --git a/mono/io-layer/processes.c b/mono/io-layer/processes.c index 5f0805878cf..d1e5a6367d0 100644 --- a/mono/io-layer/processes.c +++ b/mono/io-layer/processes.c @@ -554,6 +554,7 @@ gboolean CreateProcess (const gunichar2 *appname, const gunichar2 *cmdline, WapiStartupInfo *startup, WapiProcessInformation *process_info) { +#if defined (HAVE_FORK) && defined (HAVE_EXECVE) char *cmd = NULL, *prog = NULL, *full_prog = NULL, *args = NULL, *args_after_prog = NULL; char *dir = NULL, **env_strings = NULL, **argv = NULL; guint32 i, env_count = 0; @@ -1098,6 +1099,10 @@ free_strings: mono_processes_cleanup (); return ret; +#else + SetLastError (ERROR_NOT_SUPPORTED); + return FALSE; +#endif // defined (HAVE_FORK) && defined (HAVE_EXECVE) } static void diff --git a/mono/mini/mini-darwin.c b/mono/mini/mini-darwin.c index cb7a975f9d1..ab0024c41ba 100644 --- a/mono/mini/mini-darwin.c +++ b/mono/mini/mini-darwin.c @@ -239,12 +239,17 @@ mono_runtime_install_handlers (void) pid_t mono_runtime_syscall_fork () { +#ifdef HAVE_FORK return (pid_t) fork (); +#else + g_assert_not_reached (); +#endif } void mono_gdb_render_native_backtraces (pid_t crashed_pid) { +#ifdef HAVE_EXECV const char *argv [5]; char template [] = "/tmp/mono-gdb-commands.XXXXXX"; FILE *commands; @@ -288,6 +293,9 @@ mono_gdb_render_native_backtraces (pid_t crashed_pid) execv (argv [0], (char**)argv); unlink (template); +#else + fprintf (stderr, "mono_gdb_render_native_backtraces not supported on this platform\n"); +#endif // HAVE_EXECV } gboolean -- 2.25.1