Alexandre Julliard : kernel32: Move process name initialization to ntdll.
Alexandre Julliard
julliard at winehq.org
Tue Oct 22 16:57:00 CDT 2019
Module: wine
Branch: master
Commit: cac959920738317f14b22692a5928e0f1ef0db53
URL: https://source.winehq.org/git/wine.git/?a=commit;h=cac959920738317f14b22692a5928e0f1ef0db53
Author: Alexandre Julliard <julliard at winehq.org>
Date: Tue Oct 22 10:00:57 2019 +0200
kernel32: Move process name initialization to ntdll.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/process.c | 66 ------------------------------------------------
dlls/ntdll/thread.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 66 deletions(-)
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index a60aad6721..1f71a848a3 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -37,9 +37,6 @@
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
-#ifdef HAVE_SYS_PRCTL_H
-# include <sys/prctl.h>
-#endif
#include <sys/types.h>
#ifdef HAVE_SYS_WAIT_H
# include <sys/wait.h>
@@ -1231,68 +1228,6 @@ void WINAPI start_process( LPTHREAD_START_ROUTINE entry, PEB *peb )
}
-/***********************************************************************
- * 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 */
-}
-
-
/***********************************************************************
* __wine_kernel_init
*
@@ -1334,7 +1269,6 @@ void * CDECL __wine_kernel_init(void)
init_windows_dirs();
- set_process_name( __wine_main_argc, __wine_main_argv );
set_library_wargv( __wine_main_argv );
boot_events[0] = boot_events[1] = 0;
diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c
index 97bd4bfeb4..be54f89082 100644
--- a/dlls/ntdll/thread.c
+++ b/dlls/ntdll/thread.c
@@ -28,6 +28,9 @@
#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
@@ -147,6 +150,69 @@ static ULONG_PTR get_image_addr(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 */
+}
+
+
/***********************************************************************
* thread_init
*
@@ -245,6 +311,7 @@ void thread_init(void)
exit(1);
}
+ set_process_name( __wine_main_argc, __wine_main_argv );
init_directories();
init_user_process_params( info_size );
More information about the wine-cvs
mailing list