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

Signed-off-by: Charles Davis <cdavis5x@gmail.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Charles Davis 2016-02-19 15:33:33 -07:00 committed by Alexandre Julliard
parent 82debc093f
commit 5a4576ee09
4 changed files with 19 additions and 3 deletions

1
configure vendored
View File

@ -15047,6 +15047,7 @@ for ac_func in \
sched_yield \ sched_yield \
select \ select \
setproctitle \ setproctitle \
setprogname \
setrlimit \ setrlimit \
settimeofday \ settimeofday \
sigaltstack \ sigaltstack \

View File

@ -2026,6 +2026,7 @@ AC_CHECK_FUNCS(\
sched_yield \ sched_yield \
select \ select \
setproctitle \ setproctitle \
setprogname \
setrlimit \ setrlimit \
settimeofday \ settimeofday \
sigaltstack \ sigaltstack \

View File

@ -1118,9 +1118,20 @@ static void set_process_name( int argc, char *argv[] )
{ {
#ifdef HAVE_SETPROCTITLE #ifdef HAVE_SETPROCTITLE
setproctitle("-%s", argv[1]); 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; int i, offset;
char *p, *prctl_name = argv[1]; char *p, *prctl_name = argv[1];
char *end = argv[argc-1] + strlen(argv[argc-1]) + 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; argv[i-1] = NULL;
} }
else else
#endif /* HAVE_PRCTL */
{ {
/* remove argv[0] */ /* remove argv[0] */
memmove( argv, argv + 1, argc * sizeof(argv[0]) ); memmove( argv, argv + 1, argc * sizeof(argv[0]) );
} }
#endif /* HAVE_PRCTL */
} }

View File

@ -774,6 +774,9 @@
/* Define to 1 if you have the `setproctitle' function. */ /* Define to 1 if you have the `setproctitle' function. */
#undef HAVE_SETPROCTITLE #undef HAVE_SETPROCTITLE
/* Define to 1 if you have the `setprogname' function. */
#undef HAVE_SETPROGNAME
/* Define to 1 if you have the `setrlimit' function. */ /* Define to 1 if you have the `setrlimit' function. */
#undef HAVE_SETRLIMIT #undef HAVE_SETRLIMIT