From 34884bf5d071418e3c25e521236361e62e308025 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Wed, 24 Mar 2021 10:53:59 +0100 Subject: [PATCH] ntdll: Remove the no longer needed exec_process() function. Signed-off-by: Alexandre Julliard --- dlls/ntdll/unix/loader.c | 6 +- dlls/ntdll/unix/process.c | 155 --------------------------------- dlls/ntdll/unix/unix_private.h | 1 - include/wine/server_protocol.h | 19 +--- server/process.c | 33 ------- server/protocol.def | 7 -- server/request.h | 5 -- server/trace.c | 9 -- 8 files changed, 6 insertions(+), 229 deletions(-) diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c index c4e7e3a4146..a8b06d690a6 100644 --- a/dlls/ntdll/unix/loader.c +++ b/dlls/ntdll/unix/loader.c @@ -1763,7 +1763,11 @@ static void start_main_thread(void) load_ntdll(); load_libwine(); status = p__wine_set_unix_funcs( NTDLL_UNIXLIB_VERSION, &unix_funcs ); - if (status) exec_process( status ); + if (status == STATUS_REVISION_MISMATCH) + { + ERR( "ntdll library version mismatch\n" ); + NtTerminateProcess( GetCurrentProcess(), status ); + } server_init_process_done(); } diff --git a/dlls/ntdll/unix/process.c b/dlls/ntdll/unix/process.c index f1804009782..d2fd08e155f 100644 --- a/dlls/ntdll/unix/process.c +++ b/dlls/ntdll/unix/process.c @@ -50,10 +50,6 @@ #ifdef HAVE_UNISTD_H # include #endif -#ifdef __APPLE__ -# include -# include -#endif #ifdef HAVE_MACH_MACH_H # include #endif @@ -162,55 +158,6 @@ static char **build_argv( const UNICODE_STRING *cmdline, int reserved ) } -#ifdef __APPLE__ -/*********************************************************************** - * terminate_main_thread - * - * On some versions of Mac OS X, the execve system call fails with - * ENOTSUP if the process has multiple threads. Wine is always multi- - * threaded on Mac OS X because it specifically reserves the main thread - * for use by the system frameworks (see apple_main_thread() in - * libs/wine/loader.c). So, when we need to exec without first forking, - * we need to terminate the main thread first. We do this by installing - * a custom run loop source onto the main run loop and signaling it. - * The source's "perform" callback is pthread_exit and it will be - * executed on the main thread, terminating it. - * - * Returns TRUE if there's still hope the main thread has terminated or - * will soon. Return FALSE if we've given up. - */ -static BOOL terminate_main_thread(void) -{ - static int delayms; - - if (!delayms) - { - CFRunLoopSourceContext source_context = { 0 }; - CFRunLoopSourceRef source; - - source_context.perform = pthread_exit; - if (!(source = CFRunLoopSourceCreate( NULL, 0, &source_context ))) - return FALSE; - - CFRunLoopAddSource( CFRunLoopGetMain(), source, kCFRunLoopCommonModes ); - CFRunLoopSourceSignal( source ); - CFRunLoopWakeUp( CFRunLoopGetMain() ); - CFRelease( source ); - - delayms = 20; - } - - if (delayms > 1000) - return FALSE; - - usleep(delayms * 1000); - delayms *= 2; - - return TRUE; -} -#endif - - static inline const WCHAR *get_params_string( const RTL_USER_PROCESS_PARAMETERS *params, const UNICODE_STRING *str ) { @@ -624,108 +571,6 @@ static NTSTATUS spawn_process( const RTL_USER_PROCESS_PARAMETERS *params, int so } -/*********************************************************************** - * exec_process - */ -void DECLSPEC_NORETURN exec_process( NTSTATUS status ) -{ - RTL_USER_PROCESS_PARAMETERS *params = NtCurrentTeb()->Peb->ProcessParameters; - pe_image_info_t pe_info; - int unixdir, socketfd[2]; - char **argv; - HANDLE handle; - - if (startup_info_size) goto done; /* started from another Win32 process */ - - switch (status) - { - case STATUS_CONFLICTING_ADDRESSES: - case STATUS_NO_MEMORY: - case STATUS_INVALID_IMAGE_FORMAT: - case STATUS_INVALID_IMAGE_NOT_MZ: - { - UNICODE_STRING image; - if (getenv( "WINEPRELOADRESERVE" )) goto done; - image.Buffer = get_nt_pathname( ¶ms->ImagePathName ); - image.Length = wcslen( image.Buffer ) * sizeof(WCHAR); - if ((status = get_pe_file_info( &image, &handle, &pe_info ))) goto done; - break; - } - case STATUS_INVALID_IMAGE_WIN_16: - case STATUS_INVALID_IMAGE_NE_FORMAT: - case STATUS_INVALID_IMAGE_PROTECT: - /* we'll start winevdm */ - memset( &pe_info, 0, sizeof(pe_info) ); - pe_info.machine = IMAGE_FILE_MACHINE_I386; - break; - default: - goto done; - } - - unixdir = get_unix_curdir( params ); - - if (socketpair( PF_UNIX, SOCK_STREAM, 0, socketfd ) == -1) - { - status = STATUS_TOO_MANY_OPENED_FILES; - goto done; - } -#ifdef SO_PASSCRED - else - { - int enable = 1; - setsockopt( socketfd[0], SOL_SOCKET, SO_PASSCRED, &enable, sizeof(enable) ); - } -#endif - wine_server_send_fd( socketfd[1] ); - close( socketfd[1] ); - - SERVER_START_REQ( exec_process ) - { - req->socket_fd = socketfd[1]; - req->cpu = get_machine_cpu( &pe_info ); - status = wine_server_call( req ); - } - SERVER_END_REQ; - - if (!status) - { - if (!(argv = build_argv( ¶ms->CommandLine, 2 ))) - { - status = STATUS_NO_MEMORY; - goto done; - } - fchdir( unixdir ); - do - { - status = exec_wineloader( argv, socketfd[0], &pe_info ); - } -#ifdef __APPLE__ - while (errno == ENOTSUP && terminate_main_thread()); -#else - while (0); -#endif - free( argv ); - } - close( socketfd[0] ); - -done: - switch (status) - { - case STATUS_INVALID_IMAGE_FORMAT: - case STATUS_INVALID_IMAGE_NOT_MZ: - ERR( "%s not supported on this system\n", debugstr_us(¶ms->ImagePathName) ); - break; - case STATUS_REVISION_MISMATCH: - ERR( "ntdll library version mismatch\n" ); - break; - default: - ERR( "failed to load %s error %x\n", debugstr_us(¶ms->ImagePathName), status ); - break; - } - for (;;) NtTerminateProcess( GetCurrentProcess(), status ); -} - - /*********************************************************************** * fork_and_exec * diff --git a/dlls/ntdll/unix/unix_private.h b/dlls/ntdll/unix/unix_private.h index b2780257ccc..8e491a3f2a4 100644 --- a/dlls/ntdll/unix/unix_private.h +++ b/dlls/ntdll/unix/unix_private.h @@ -224,7 +224,6 @@ extern void *signal_init_syscalls(void) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN signal_start_thread( PRTL_THREAD_START_ROUTINE entry, void *arg, BOOL suspend, void *thunk, TEB *teb ) DECLSPEC_HIDDEN; extern void DECLSPEC_NORETURN signal_exit_thread( int status, void (*func)(int) ) DECLSPEC_HIDDEN; -extern void DECLSPEC_NORETURN exec_process( NTSTATUS status ) DECLSPEC_HIDDEN; extern void __wine_syscall_dispatcher(void) DECLSPEC_HIDDEN; extern void signal_restore_full_cpu_context(void) DECLSPEC_HIDDEN; extern void fill_vm_counters( VM_COUNTERS_EX *pvmi, int unix_pid ) DECLSPEC_HIDDEN; diff --git a/include/wine/server_protocol.h b/include/wine/server_protocol.h index e948799b05d..36506bd258d 100644 --- a/include/wine/server_protocol.h +++ b/include/wine/server_protocol.h @@ -857,20 +857,6 @@ struct new_process_reply -struct exec_process_request -{ - struct request_header __header; - int socket_fd; - client_cpu_t cpu; - char __pad_20[4]; -}; -struct exec_process_reply -{ - struct reply_header __header; -}; - - - struct get_new_process_info_request { struct request_header __header; @@ -5406,7 +5392,6 @@ struct resume_process_reply enum request { REQ_new_process, - REQ_exec_process, REQ_get_new_process_info, REQ_new_thread, REQ_get_startup_info, @@ -5687,7 +5672,6 @@ union generic_request struct request_max_size max_size; struct request_header request_header; struct new_process_request new_process_request; - struct exec_process_request exec_process_request; struct get_new_process_info_request get_new_process_info_request; struct new_thread_request new_thread_request; struct get_startup_info_request get_startup_info_request; @@ -5966,7 +5950,6 @@ union generic_reply struct request_max_size max_size; struct reply_header reply_header; struct new_process_reply new_process_reply; - struct exec_process_reply exec_process_reply; struct get_new_process_info_reply get_new_process_info_reply; struct new_thread_reply new_thread_reply; struct get_startup_info_reply get_startup_info_reply; @@ -6243,7 +6226,7 @@ union generic_reply /* ### protocol_version begin ### */ -#define SERVER_PROTOCOL_VERSION 687 +#define SERVER_PROTOCOL_VERSION 688 /* ### protocol_version end ### */ diff --git a/server/process.c b/server/process.c index 571a80f0dc6..7bc096a7b1f 100644 --- a/server/process.c +++ b/server/process.c @@ -1212,39 +1212,6 @@ DECL_HANDLER(new_process) release_object( info ); } -/* execute a new process, replacing the existing one */ -DECL_HANDLER(exec_process) -{ - struct process *process; - int socket_fd = thread_get_inflight_fd( current, req->socket_fd ); - - if (socket_fd == -1) - { - set_error( STATUS_INVALID_PARAMETER ); - return; - } - if (fcntl( socket_fd, F_SETFL, O_NONBLOCK ) == -1) - { - set_error( STATUS_INVALID_HANDLE ); - close( socket_fd ); - return; - } - if (shutdown_stage) - { - set_error( STATUS_SHUTDOWN_IN_PROGRESS ); - close( socket_fd ); - return; - } - if (!is_cpu_supported( req->cpu )) - { - close( socket_fd ); - return; - } - if (!(process = create_process( socket_fd, NULL, 0, NULL, NULL, NULL, 0, NULL ))) return; - create_thread( -1, process, NULL ); - release_object( process ); -} - /* Retrieve information about a newly started process */ DECL_HANDLER(get_new_process_info) { diff --git a/server/protocol.def b/server/protocol.def index c2792e9551c..be524f92868 100644 --- a/server/protocol.def +++ b/server/protocol.def @@ -865,13 +865,6 @@ typedef struct @END -/* Execute a process, replacing the current one */ -@REQ(exec_process) - int socket_fd; /* file descriptor for process socket */ - client_cpu_t cpu; /* CPU that the new process will use */ -@END - - /* Retrieve information about a newly started process */ @REQ(get_new_process_info) obj_handle_t info; /* info handle returned from new_process_request */ diff --git a/server/request.h b/server/request.h index a4d003e5c6a..d0baa089b4e 100644 --- a/server/request.h +++ b/server/request.h @@ -120,7 +120,6 @@ static inline void set_reply_data_ptr( void *data, data_size_t size ) /* ### make_requests begin ### */ DECL_HANDLER(new_process); -DECL_HANDLER(exec_process); DECL_HANDLER(get_new_process_info); DECL_HANDLER(new_thread); DECL_HANDLER(get_startup_info); @@ -400,7 +399,6 @@ typedef void (*req_handler)( const void *req, void *reply ); static const req_handler req_handlers[REQ_NB_REQUESTS] = { (req_handler)req_new_process, - (req_handler)req_exec_process, (req_handler)req_get_new_process_info, (req_handler)req_new_thread, (req_handler)req_get_startup_info, @@ -721,9 +719,6 @@ C_ASSERT( FIELD_OFFSET(struct new_process_reply, info) == 8 ); C_ASSERT( FIELD_OFFSET(struct new_process_reply, pid) == 12 ); C_ASSERT( FIELD_OFFSET(struct new_process_reply, handle) == 16 ); C_ASSERT( sizeof(struct new_process_reply) == 24 ); -C_ASSERT( FIELD_OFFSET(struct exec_process_request, socket_fd) == 12 ); -C_ASSERT( FIELD_OFFSET(struct exec_process_request, cpu) == 16 ); -C_ASSERT( sizeof(struct exec_process_request) == 24 ); C_ASSERT( FIELD_OFFSET(struct get_new_process_info_request, info) == 12 ); C_ASSERT( sizeof(struct get_new_process_info_request) == 16 ); C_ASSERT( FIELD_OFFSET(struct get_new_process_info_reply, success) == 8 ); diff --git a/server/trace.c b/server/trace.c index c0d2e3dfab7..b45dfc286b7 100644 --- a/server/trace.c +++ b/server/trace.c @@ -1388,12 +1388,6 @@ static void dump_new_process_reply( const struct new_process_reply *req ) fprintf( stderr, ", handle=%04x", req->handle ); } -static void dump_exec_process_request( const struct exec_process_request *req ) -{ - fprintf( stderr, " socket_fd=%d", req->socket_fd ); - dump_client_cpu( ", cpu=", &req->cpu ); -} - static void dump_get_new_process_info_request( const struct get_new_process_info_request *req ) { fprintf( stderr, " info=%04x", req->info ); @@ -4462,7 +4456,6 @@ static void dump_resume_process_request( const struct resume_process_request *re static const dump_func req_dumpers[REQ_NB_REQUESTS] = { (dump_func)dump_new_process_request, - (dump_func)dump_exec_process_request, (dump_func)dump_get_new_process_info_request, (dump_func)dump_new_thread_request, (dump_func)dump_get_startup_info_request, @@ -4739,7 +4732,6 @@ static const dump_func req_dumpers[REQ_NB_REQUESTS] = { static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { (dump_func)dump_new_process_reply, - NULL, (dump_func)dump_get_new_process_info_reply, (dump_func)dump_new_thread_reply, (dump_func)dump_get_startup_info_reply, @@ -5016,7 +5008,6 @@ static const dump_func reply_dumpers[REQ_NB_REQUESTS] = { static const char * const req_names[REQ_NB_REQUESTS] = { "new_process", - "exec_process", "get_new_process_info", "new_thread", "get_startup_info",