kernel: Simplify set_process_name now that it doesn't have to handle winevdm.

This commit is contained in:
Alexandre Julliard 2006-07-19 15:04:57 +02:00
parent 2cb0f43224
commit 763e96abae
1 changed files with 15 additions and 40 deletions

View File

@ -463,6 +463,7 @@ static void set_library_wargv( char **argv )
} }
argv[argc] = NULL; argv[argc] = NULL;
__wine_main_argc = argc;
__wine_main_argv = argv; __wine_main_argv = argv;
__wine_main_wargv = wargv; __wine_main_wargv = wargv;
} }
@ -816,59 +817,33 @@ static void start_process( void *arg )
* *
* Change the process name in the ps output. * Change the process name in the ps output.
*/ */
static void set_process_name( int *argc, char *argv[], char *name ) static void set_process_name( int argc, char *argv[] )
{ {
#ifdef HAVE_PRCTL #ifdef HAVE_PRCTL
int i, offset; int i, offset;
char *prctl_name = NULL; 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;
#ifndef PR_SET_NAME #ifndef PR_SET_NAME
# define PR_SET_NAME 15 # define PR_SET_NAME 15
#endif #endif
if (!name) if ((p = strrchr( prctl_name, '\\' ))) prctl_name = p + 1;
{ if ((p = strrchr( prctl_name, '/' ))) prctl_name = p + 1;
char *p;
prctl_name = argv[1];
if ((p = strrchr( prctl_name, '\\' ))) prctl_name = p + 1;
if ((p = strrchr( prctl_name, '/' ))) prctl_name = p + 1;
}
else
{
if (strlen(name) <= strlen(argv[0])) prctl_name = name;
}
if (prctl_name && prctl( PR_SET_NAME, prctl_name ) != -1) if (prctl( PR_SET_NAME, prctl_name ) != -1)
{ {
if (name) offset = argv[1] - argv[0];
{ memmove( argv[1] - offset, argv[1], end - argv[1] );
strcpy( argv[0], name ); memset( end - offset, 0, offset );
offset = argv[1] - (argv[0] + strlen(name) + 1); for (i = 1; i < argc; i++) argv[i-1] = argv[i] - offset;
memmove( argv[1] - offset, argv[1], end - argv[1] ); argv[i-1] = NULL;
memset( end - offset, 0, offset );
for (i = 1; i < *argc; i++) argv[i] -= offset;
}
else
{
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;
(*argc)--;
}
} }
else else
#endif /* HAVE_PRCTL */ #endif /* HAVE_PRCTL */
{ {
if (name) argv[0] = name; /* remove argv[0] */
else memmove( argv, argv + 1, argc * sizeof(argv[0]) );
{
/* remove argv[0] */
memmove( argv, argv + 1, *argc * sizeof(argv[0]) );
(*argc)--;
}
} }
} }
@ -888,7 +863,7 @@ void __wine_kernel_init(void)
/* Initialize everything */ /* Initialize everything */
if (!process_init()) exit(1); if (!process_init()) exit(1);
set_process_name( &__wine_main_argc, __wine_main_argv, NULL ); set_process_name( __wine_main_argc, __wine_main_argv );
set_library_wargv( __wine_main_argv ); set_library_wargv( __wine_main_argv );
if (peb->ProcessParameters->ImagePathName.Buffer) if (peb->ProcessParameters->ImagePathName.Buffer)