Hi,

On Sunday, November 07, 2010 16:44:12 John Morrissey wrote:
> -    if (prctl(PR_SET_NAME, name)) {
> -        perror("unable to change process name");
> -        exit(1);
> -    }
> +
> +    last_argv_byte = argv[argc - 1] + strlen(argv[argc - 1]);
> +
> +    len = snprintf(argv[0], last_argv_byte - argv[0], "%s", name);
> +
> +    p = &argv[0][len];
> +    while (p <= last_argv_byte)
> +        *p++ = '\0';
> +    for (i = 1; i < argc; ++i)
> +        argv[i] = (char *) "";

I am quite new to the list but why not do both call prctl(PR_SET_NAME, name) 
and overwrite argv?

The point is some tools read /proc/PID/cmdline but others the name field in 
/proc/PID/status. The former is changed by overwriting argv the latter by 
prctl.

Torsten Förtsch

-- 
Need professional modperl support? Hire me! (http://foertsch.name)

Like fantasy? http://kabatinte.net

Reply via email to