Setup signal handling and exceptions only after REQ_INIT_PROCESS_DONE has been sent, to avoid deadlocking the debugger.
diff --git a/scheduler/client.c b/scheduler/client.c index ffb33fc..324aaf7 100644 --- a/scheduler/client.c +++ b/scheduler/client.c
@@ -11,6 +11,7 @@ #include <errno.h> #include <fcntl.h> #include <pwd.h> +#include <signal.h> #include <stdio.h> #include <string.h> #include <sys/types.h> @@ -411,16 +412,19 @@ fatal_error( "'%s/%s' is not owned by you\n", serverdir, SOCKETNAME ); /* try to connect to it */ - if ((s = socket( AF_UNIX, SOCK_STREAM, 0 )) == -1) fatal_perror( "socket" ); addr.sun_family = AF_UNIX; strcpy( addr.sun_path, SOCKETNAME ); slen = sizeof(addr) - sizeof(addr.sun_path) + strlen(addr.sun_path) + 1; #ifdef HAVE_SOCKADDR_SUN_LEN addr.sun_len = slen; #endif + if ((s = socket( AF_UNIX, SOCK_STREAM, 0 )) == -1) fatal_perror( "socket" ); if (connect( s, (struct sockaddr *)&addr, slen ) == -1) { - usleep( 50000 ); /* in case the server was starting right now */ + close( s ); + /* wait a bit and retry with a new socket */ + usleep( 50000 ); + if ((s = socket( AF_UNIX, SOCK_STREAM, 0 )) == -1) fatal_perror( "socket" ); if (connect( s, (struct sockaddr *)&addr, slen ) == -1) fatal_error( "'%s/%s' exists,\n" " but I cannot connect to it; maybe the server has crashed?\n" @@ -440,18 +444,10 @@ int CLIENT_InitServer(void) { int fd, size; - const char *env_fd; char hostname[64]; char *oldcwd, *serverdir; const char *configdir; - /* first check if we inherited the socket fd */ - if ((env_fd = getenv( "__WINE_FD" )) && isdigit(env_fd[0])) - { - fd = atoi( env_fd ); - if (fcntl( fd, F_SETFD, 1 ) != -1) return fd; /* set close on exec flag */ - } - /* retrieve the current directory */ for (size = 512; ; size *= 2) { @@ -497,6 +493,9 @@ TEB *teb = NtCurrentTeb(); int fd; + /* ignore SIGPIPE so that we get a EPIPE error instead */ + signal( SIGPIPE, SIG_IGN ); + if (wait_reply_fd( &fd ) || (fd == -1)) server_protocol_error( "no fd passed on first request\n" ); if ((teb->buffer_size = lseek( fd, 0, SEEK_END )) == -1) server_perror( "lseek" );