Last active
May 31, 2020 18:50
-
-
Save mmtrt/2189f831f11060d10d3df0e91efa274b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From acd209d6039f2492bdc8aca3d15bb1b268b04f1a Mon Sep 17 00:00:00 2001 | |
From: Alexandre Julliard <[email protected]> | |
Date: Wed, 20 May 2020 15:51:19 +0200 | |
Subject: [PATCH] ntdll: Move setting the process name to the Unix library. | |
Signed-off-by: Alexandre Julliard <[email protected]> | |
Modified-by: Taqi Raza | |
--- | |
dlls/ntdll/thread.c | 65 -------------------------------------- | |
dlls/ntdll/unix/loader.c | 67 ++++++++++++++++++++++++++++++++++++++++ | |
2 files changed, 67 insertions(+), 65 deletions(-) | |
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c | |
index a5e1fadac9..238a63aad0 100644 | |
--- a/dlls/ntdll/thread.c | |
+++ b/dlls/ntdll/thread.c | |
@@ -28,9 +28,6 @@ | |
#ifdef HAVE_SYS_MMAN_H | |
#include <sys/mman.h> | |
#endif | |
-#ifdef HAVE_SYS_PRCTL_H | |
-# include <sys/prctl.h> | |
-#endif | |
#ifdef HAVE_SYS_TIMES_H | |
#include <sys/times.h> | |
#endif | |
@@ -187,67 +184,6 @@ int __cdecl __wine_dbg_output( const char *str ) | |
return unix_funcs->dbg_output( str ); | |
} | |
-/*********************************************************************** | |
- * set_process_name | |
- * | |
- * Change the process name in the ps output. | |
- */ | |
-static void set_process_name( int argc, char *argv[] ) | |
-{ | |
- BOOL shift_strings; | |
- char *p, *name; | |
- int i; | |
- | |
-#ifdef HAVE_SETPROCTITLE | |
- setproctitle("-%s", argv[1]); | |
- shift_strings = FALSE; | |
-#else | |
- p = argv[0]; | |
- | |
- shift_strings = (argc >= 2); | |
- for (i = 1; i < argc; i++) | |
- { | |
- p += strlen(p) + 1; | |
- if (p != argv[i]) | |
- { | |
- shift_strings = FALSE; | |
- break; | |
- } | |
- } | |
-#endif | |
- | |
- if (shift_strings) | |
- { | |
- int offset = argv[1] - argv[0]; | |
- char *end = argv[argc-1] + strlen(argv[argc-1]) + 1; | |
- memmove( argv[0], argv[1], end - argv[1] ); | |
- memset( end - offset, 0, offset ); | |
- for (i = 1; i < argc; i++) | |
- argv[i-1] = argv[i] - offset; | |
- argv[i-1] = NULL; | |
- } | |
- else | |
- { | |
- /* remove argv[0] */ | |
- memmove( argv, argv + 1, argc * sizeof(argv[0]) ); | |
- } | |
- | |
- name = argv[0]; | |
- if ((p = strrchr( name, '\\' ))) name = p + 1; | |
- if ((p = strrchr( name, '/' ))) name = p + 1; | |
- | |
-#if defined(HAVE_SETPROGNAME) | |
- setprogname( name ); | |
-#endif | |
- | |
-#ifdef HAVE_PRCTL | |
-#ifndef PR_SET_NAME | |
-# define PR_SET_NAME 15 | |
-#endif | |
- prctl( PR_SET_NAME, name ); | |
-#endif /* HAVE_PRCTL */ | |
-} | |
- | |
HANDLE user_shared_data_init_done(void) | |
{ | |
static const WCHAR wine_usdW[] = {'\\','K','e','r','n','e','l','O','b','j','e','c','t','s', | |
@@ -382,7 +318,6 @@ TEB *thread_init(void) | |
unix_funcs->dbg_init(); | |
unix_funcs->get_paths( &build_dir, &data_dir, &config_dir ); | |
- set_process_name( __wine_main_argc, __wine_main_argv ); | |
fill_cpu_info(); | |
return teb; | |
/* initialize time values in user_shared_data */ | |
NtQuerySystemTime( &now ); | |
diff --git a/dlls/ntdll/unix/loader.c b/dlls/ntdll/unix/loader.c | |
index 1ba6f686fb..d4480e86f0 100644 | |
--- a/dlls/ntdll/unix/loader.c | |
+++ b/dlls/ntdll/unix/loader.c | |
@@ -38,6 +38,9 @@ | |
#ifdef HAVE_SYS_MMAN_H | |
# include <sys/mman.h> | |
#endif | |
+#ifdef HAVE_SYS_PRCTL_H | |
+# include <sys/prctl.h> | |
+#endif | |
#ifdef HAVE_SYS_RESOURCE_H | |
# include <sys/resource.h> | |
#endif | |
@@ -1192,6 +1195,68 @@ static int pre_exec(void) | |
#endif | |
+/*********************************************************************** | |
+ * set_process_name | |
+ * | |
+ * Change the process name in the ps output. | |
+ */ | |
+static void set_process_name( int argc, char *argv[] ) | |
+{ | |
+ BOOL shift_strings; | |
+ char *p, *name; | |
+ int i; | |
+ | |
+#ifdef HAVE_SETPROCTITLE | |
+ setproctitle("-%s", argv[1]); | |
+ shift_strings = FALSE; | |
+#else | |
+ p = argv[0]; | |
+ | |
+ shift_strings = (argc >= 2); | |
+ for (i = 1; i < argc; i++) | |
+ { | |
+ p += strlen(p) + 1; | |
+ if (p != argv[i]) | |
+ { | |
+ shift_strings = FALSE; | |
+ break; | |
+ } | |
+ } | |
+#endif | |
+ | |
+ if (shift_strings) | |
+ { | |
+ int offset = argv[1] - argv[0]; | |
+ char *end = argv[argc-1] + strlen(argv[argc-1]) + 1; | |
+ memmove( argv[0], argv[1], end - argv[1] ); | |
+ memset( end - offset, 0, offset ); | |
+ for (i = 1; i < argc; i++) | |
+ argv[i-1] = argv[i] - offset; | |
+ argv[i-1] = NULL; | |
+ } | |
+ else | |
+ { | |
+ /* remove argv[0] */ | |
+ memmove( argv, argv + 1, argc * sizeof(argv[0]) ); | |
+ } | |
+ | |
+ name = argv[0]; | |
+ if ((p = strrchr( name, '\\' ))) name = p + 1; | |
+ if ((p = strrchr( name, '/' ))) name = p + 1; | |
+ | |
+#if defined(HAVE_SETPROGNAME) | |
+ setprogname( name ); | |
+#endif | |
+ | |
+#ifdef HAVE_PRCTL | |
+#ifndef PR_SET_NAME | |
+# define PR_SET_NAME 15 | |
+#endif | |
+ prctl( PR_SET_NAME, name ); | |
+#endif /* HAVE_PRCTL */ | |
+} | |
+ | |
+ | |
/*********************************************************************** | |
* check_command_line | |
* | |
@@ -1260,6 +1325,7 @@ void __wine_main( int argc, char *argv[], char *envp[] ) | |
module = load_ntdll(); | |
fixup_ntdll_imports( &__wine_spec_nt_header, module ); | |
+ set_process_name( argc, argv ); | |
init_unix_codepage(); | |
#ifdef __APPLE__ | |
@@ -1294,6 +1360,7 @@ NTSTATUS __cdecl __wine_init_unix_lib( HMODULE module, const void *ptr_in, void | |
map_so_dll( nt, module ); | |
fixup_ntdll_imports( &__wine_spec_nt_header, module ); | |
+ set_process_name( __wine_main_argc, __wine_main_argv ); | |
init_unix_codepage(); | |
*(struct unix_funcs **)ptr_out = &unix_funcs; | |
wine_mmap_enum_reserved_areas( add_area, NULL, 0 ); | |
-- | |
2.20.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment