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

Alexandre Julliard julliard at winehq.org
Fri Feb 19 04:58:56 CST 2016


Charles Davis <cdavis5x at gmail.com> writes:

> @@ -1118,21 +1118,29 @@ static void set_process_name( int argc, char *argv[] )
>  {
>  #ifdef HAVE_SETPROCTITLE
>      setproctitle("-%s", argv[1]);
> -#endif
> -
> -#ifdef HAVE_PRCTL
> +#elif defined(HAVE_PRCTL) || defined(HAVE_SETPROGNAME)
>      int i, offset;
>      char *p, *prctl_name = argv[1];
>      char *end = argv[argc-1] + strlen(argv[argc-1]) + 1;
> -
> -#ifndef PR_SET_NAME
> -# define PR_SET_NAME 15
> +#ifdef HAVE_SETPROGNAME
> +    static char progname[PATH_MAX];
>  #endif
>  
>      if ((p = strrchr( prctl_name, '\\' ))) prctl_name = p + 1;
>      if ((p = strrchr( prctl_name, '/' ))) prctl_name = p + 1;
>  
> +#ifdef HAVE_SETPROGNAME
> +    lstrcpynA( progname, prctl_name, sizeof(progname)/sizeof(progname[0]) );
> +    progname[PATH_MAX-1] = 0;
> +    setprogname( progname );
> +    if (1)
> +#elif defined(HAVE_PRCTL)
> +#ifndef PR_SET_NAME
> +# define PR_SET_NAME 15
> +#endif
> +
>      if (prctl( PR_SET_NAME, prctl_name ) != -1)
> +#endif

This is becoming hard to follow, please try to clean up these #ifdefs a
little. Also you shouldn't need to make a copy, it can point directly
into argv.

-- 
Alexandre Julliard
julliard at winehq.org



More information about the wine-devel mailing list