Charles Davis : kernel32: Use setprogname(3) to set the program name if available.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Feb 22 08:57:38 CST 2016


Module: wine
Branch: master
Commit: 5a4576ee09cff4a886c2d502bde7d1d6418a0ee5
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=5a4576ee09cff4a886c2d502bde7d1d6418a0ee5

Author: Charles Davis <cdavis5x at gmail.com>
Date:   Fri Feb 19 15:33:33 2016 -0700

kernel32: Use setprogname(3) to set the program name if available.

Signed-off-by: Charles Davis <cdavis5x at gmail.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 configure               |  1 +
 configure.ac            |  1 +
 dlls/kernel32/process.c | 17 ++++++++++++++---
 include/config.h.in     |  3 +++
 4 files changed, 19 insertions(+), 3 deletions(-)

diff --git a/configure b/configure
index 8529306..8200927 100755
--- a/configure
+++ b/configure
@@ -15047,6 +15047,7 @@ for ac_func in \
 	sched_yield \
 	select \
 	setproctitle \
+	setprogname \
 	setrlimit \
 	settimeofday \
 	sigaltstack \
diff --git a/configure.ac b/configure.ac
index c9445e7..2ebbb10 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2026,6 +2026,7 @@ AC_CHECK_FUNCS(\
 	sched_yield \
 	select \
 	setproctitle \
+	setprogname \
 	setrlimit \
 	settimeofday \
 	sigaltstack \
diff --git a/dlls/kernel32/process.c b/dlls/kernel32/process.c
index 86333be..4771108 100644
--- a/dlls/kernel32/process.c
+++ b/dlls/kernel32/process.c
@@ -1118,9 +1118,20 @@ static void set_process_name( int argc, char *argv[] )
 {
 #ifdef HAVE_SETPROCTITLE
     setproctitle("-%s", argv[1]);
-#endif
+    /* remove argv[0] */
+    memmove( argv, argv + 1, argc * sizeof(argv[0]) );
+#elif defined(HAVE_SETPROGNAME)
+    int i, offset;
+    char *end = argv[argc-1] + strlen(argv[argc-1]) + 1;
 
-#ifdef HAVE_PRCTL
+    offset = argv[1] - argv[0];
+    memmove( argv[1] - offset, 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;
+
+    setprogname( argv[0] );
+#elif defined(HAVE_PRCTL)
     int i, offset;
     char *p, *prctl_name = argv[1];
     char *end = argv[argc-1] + strlen(argv[argc-1]) + 1;
@@ -1141,11 +1152,11 @@ static void set_process_name( int argc, char *argv[] )
         argv[i-1] = NULL;
     }
     else
-#endif  /* HAVE_PRCTL */
     {
         /* remove argv[0] */
         memmove( argv, argv + 1, argc * sizeof(argv[0]) );
     }
+#endif  /* HAVE_PRCTL */
 }
 
 
diff --git a/include/config.h.in b/include/config.h.in
index 86318c5..86da1a5 100644
--- a/include/config.h.in
+++ b/include/config.h.in
@@ -774,6 +774,9 @@
 /* Define to 1 if you have the `setproctitle' function. */
 #undef HAVE_SETPROCTITLE
 
+/* Define to 1 if you have the `setprogname' function. */
+#undef HAVE_SETPROGNAME
+
 /* Define to 1 if you have the `setrlimit' function. */
 #undef HAVE_SETRLIMIT
 




More information about the wine-cvs mailing list