Rename the process back to wine on 2.6 kernels
Mike Hearn
mike at navi.cx
Sun Mar 27 09:50:23 CST 2005
This makes us appear as "wine" again on 2.6 kernels, instead of appearing as
/usr/bin/wine-preloader. It works in ps, top, and killall which are the most
important. On kernels that don't support it, we will still appear as
wine-preloader though.
If this patch is accepted I might do another to move the [pk]thread switch
into an env var instead of the command line. Then we'd be back to
"wine foobar.exe" just like the good old days ;)
ChangeLog:
Rename process back to wine on kernels that support PR_SET_NAME
Index: libs/wine/loader.c
===================================================================
RCS file: /home/wine/wine/libs/wine/loader.c,v
retrieving revision 1.22
diff -u -p -d -r1.22 loader.c
--- libs/wine/loader.c 3 Sep 2004 17:28:39 -0000 1.22
+++ libs/wine/loader.c 27 Mar 2005 15:39:12 -0000
@@ -28,8 +28,14 @@
#include <stdlib.h>
#include <string.h>
#include <sys/types.h>
+#ifdef HAVE_SYS_PRCTL_H
+# include <sys/prctl.h>
+# ifndef PR_SET_NAME
+# define PR_SET_NAME 15
+# endif
+#endif
#ifdef HAVE_SYS_MMAN_H
-#include <sys/mman.h>
+# include <sys/mman.h>
#endif
#ifdef HAVE_UNISTD_H
# include <unistd.h>
@@ -528,6 +534,12 @@ void wine_init( int argc, char *argv[],
build_dll_path();
wine_init_argv0_path( argv[0] );
+
+#ifdef HAVE_SYS_PRCTL_H
+ /* rename on 2.6 kernels for "top" and "killall" */
+ prctl(PR_SET_NAME, (unsigned long) "wine", 0, 0, 0);
+#endif
+
__wine_main_argc = argc;
__wine_main_argv = argv;
__wine_main_environ = environ;
Index: libs/wine/config.c
===================================================================
RCS file: /home/wine/wine/libs/wine/config.c,v
retrieving revision 1.12
diff -u -p -d -r1.12 config.c
--- libs/wine/config.c 20 Dec 2004 18:55:18 -0000 1.12
+++ libs/wine/config.c 27 Mar 2005 15:39:13 -0000
@@ -30,6 +30,12 @@
#ifdef HAVE_UNISTD_H
# include <unistd.h>
#endif
+#ifdef HAVE_SYS_PRCTL_H
+# include <sys/prctl.h>
+# ifndef PR_SET_NAME
+# define PR_SET_NAME 15
+# endif
+#endif
#ifdef HAVE_PWD_H
#include <pwd.h>
#endif
@@ -289,6 +295,11 @@ static void preloader_exec( char **argv,
new_argv = xmalloc( (last_arg - argv + 2) * sizeof(*argv) );
memcpy( new_argv + 1, argv, (last_arg - argv + 1) * sizeof(*argv) );
new_argv[0] = full_name;
+
+ /* does this kernel supports setting the process name? */
+ if (prctl(PR_SET_NAME, (unsigned long) argv0_name, 0, 0, 0) >= 0)
+ new_argv[0] = argv0_name;
+
if (envp) execve( full_name, new_argv, envp );
else execv( full_name, new_argv );
free( new_argv );
Index: configure.ac
===================================================================
RCS file: /home/wine/wine/configure.ac,v
retrieving revision 1.344
diff -u -p -d -r1.344 configure.ac
--- configure.ac 19 Mar 2005 17:08:18 -0000 1.344
+++ configure.ac 27 Mar 2005 15:39:17 -0000
@@ -225,6 +225,7 @@ AC_CHECK_HEADERS(\
sys/msg.h \
sys/param.h \
sys/poll.h \
+ sys/prctl.h \
sys/ptrace.h \
sys/reg.h \
sys/scsiio.h \
Index: include/config.h.in
===================================================================
RCS file: /home/wine/wine/include/config.h.in,v
retrieving revision 1.214
diff -u -p -d -r1.214 config.h.in
--- include/config.h.in 4 Mar 2005 12:38:37 -0000 1.214
+++ include/config.h.in 27 Mar 2005 15:39:18 -0000
@@ -647,6 +647,9 @@
/* Define to 1 if you have the <sys/poll.h> header file. */
#undef HAVE_SYS_POLL_H
+/* Define to 1 if you have the <sys/prctl.h> header file. */
+#undef HAVE_SYS_PRCTL_H
+
/* Define to 1 if you have the <sys/ptrace.h> header file. */
#undef HAVE_SYS_PTRACE_H
More information about the wine-patches
mailing list