From: Brendan Shanks bshanks@codeweavers.com
--- dlls/ntdll/unix/loader.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-)
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index c184a2d5c4a..b9da6e74fd7 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -30,6 +30,7 @@ #include <stdarg.h> #include <stdio.h> #include <signal.h> +#include <spawn.h> #include <string.h> #include <stdlib.h> #include <sys/types.h> @@ -69,7 +70,6 @@ # include <mach/mach_error.h> # include <mach-o/getsect.h> # include <crt_externs.h> -# include <spawn.h> # ifndef _POSIX_SPAWN_DISABLE_ASLR # define _POSIX_SPAWN_DISABLE_ASLR 0x0100 # endif @@ -77,6 +77,7 @@ #ifdef __ANDROID__ # include <jni.h> #endif +extern char **environ;
#include "ntstatus.h" #define WIN32_NO_STATUS @@ -636,18 +637,23 @@ void start_server( BOOL debug )
if (!started) { - int status; + int status = 1; + pid_t pid; char *pathcopy = NULL; - int pid = fork(); - if (pid == -1) fatal_error( "fork: %s", strerror(errno) ); - if (!pid) + + argv[1] = debug ? debug_flag : NULL; + argv[2] = NULL; + + while ((argv[0] = next_wineserver_path( &pathcopy ))) { - argv[1] = debug ? debug_flag : NULL; - argv[2] = NULL; - while ((argv[0] = next_wineserver_path( &pathcopy ))) - execv( argv[0], argv ); - fatal_error( "could not exec wineserver\n" ); + status = posix_spawn( &pid, argv[0], NULL, NULL, argv, environ ); + free( argv[0] ); + if (!status) + break; } + free( pathcopy ); + if (status) fatal_error( "could not spawn wineserver\n" ); + waitpid( pid, &status, 0 ); status = WIFEXITED(status) ? WEXITSTATUS(status) : 1; if (status == 2) return; /* server lock held by someone else, will retry later */