dlls/ntdll/server.c
/***********************************************************************
 *           server_init_process
 *
 * Start the server and create the initial socket pair.
 */
server_init_process
Start the server and create the initial socket pair.
server_init_process Start the server and create the initial socket pair .
void server_init_process(void)
{
    obj_handle_t version;
    const char *env_socket = getenv( "WINESERVERSOCKET" );
    server_pid = -1;
    if (env_socket)
    {
        fd_socket = atoi( env_socket );
        if (fcntl( fd_socket, F_SETFD, 1 ) == -1)
            fatal_perror( "Bad server socket %d", fd_socket );
        unsetenv( "WINESERVERSOCKET" );
    }
    else fd_socket = server_connect();
    sigemptyset( &server_block_set );
    sigaddset( &server_block_set, SIGALRM );
    sigaddset( &server_block_set, SIGIO );
    sigaddset( &server_block_set, SIGINT );
    sigaddset( &server_block_set, SIGHUP );
    sigaddset( &server_block_set, SIGUSR1 );
    sigaddset( &server_block_set, SIGUSR2 );
    sigaddset( &server_block_set, SIGCHLD );
    pthread_sigmask( SIG_BLOCK, &server_block_set, NULL );
    ntdll_get_thread_data()->request_fd = receive_fd( &version );
#ifdef SO_PASSCRED
    {
        int enable = 0;
        setsockopt( fd_socket, SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable) );
    }
#endif
    if (version != SERVER_PROTOCOL_VERSION)
        server_protocol_error( "version mismatch %d/%d.\n"
                               "Your %s binary was not upgraded correctly,\n"
                               "or you have an older one somewhere in your PATH.\n"
                               "Or maybe the wrong wineserver is still running?\n",
                               version, SERVER_PROTOCOL_VERSION,
                               (version > SERVER_PROTOCOL_VERSION) ? "wine" : "wineserver" );
#ifdef __APPLE__
    send_server_task_port();
#endif
#if defined(__linux__) && defined(HAVE_PRCTL)
    if (server_pid != -1) prctl( 0x59616d61 , server_pid );
#endif
}
void server_init_process ( void ) { obj_handle_t version ; const char * env_socket = getenv ( " " ) ; server_pid = -1 ; if ( env_socket ) { fd_socket = atoi ( env_socket ) ; if ( fcntl ( fd_socket , F_SETFD , 1 ) == -1 ) fatal_perror ( " " , fd_socket ) ; unsetenv ( " " ) ; } else fd_socket = server_connect ( ) ; sigemptyset ( & server_block_set ) ; sigaddset ( & server_block_set , SIGALRM ) ; sigaddset ( & server_block_set , SIGIO ) ; sigaddset ( & server_block_set , SIGINT ) ; sigaddset ( & server_block_set , SIGHUP ) ; sigaddset ( & server_block_set , SIGUSR1 ) ; sigaddset ( & server_block_set , SIGUSR2 ) ; sigaddset ( & server_block_set , SIGCHLD ) ; pthread_sigmask ( SIG_BLOCK , & server_block_set , NULL ) ; ntdll_get_thread_data ( ) -> request_fd = receive_fd ( & version ) ; #ifdef SO_PASSCRED { int enable = 0 ; setsockopt ( fd_socket , SOL_SOCKET , SO_PASSCRED , & enable , sizeof ( enable ) ) ; } #endif if ( version != SERVER_PROTOCOL_VERSION ) server_protocol_error ( " \n " " \n " " \n " " \n " , version , SERVER_PROTOCOL_VERSION , ( version > SERVER_PROTOCOL_VERSION ) ? " " : " " ) ; #ifdef __APPLE__ send_server_task_port ( ) ; #endif #if defined ( __linux__ ) && defined ( HAVE_PRCTL ) if ( server_pid != -1 ) prctl ( 0x59616d61 , server_pid ) ; #endif }
server_init_process
 Start the server and create the initial socket pair.
server_init_process Start the server and create the initial socket pair .
/* setup the signal mask */ /* receive the first thread request fd on the main socket */ /* now that we hopefully received the server_pid, disable SO_PASSCRED */ /* work around Ubuntu's ptrace breakage */ /* PR_SET_PTRACER */