All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Torsten Förtsch" <torsten.foertsch@gmx.net>
To: qemu-devel@nongnu.org
Cc: John Morrissey <jwm@horde.net>
Subject: Re: [Qemu-devel] [PATCH] Overwrite argv to set process title, eliminating 16-character prctl() limit.
Date: Sun, 7 Nov 2010 21:49:27 +0100	[thread overview]
Message-ID: <201011072149.28266.torsten.foertsch@gmx.net> (raw)
In-Reply-To: <1289144652-23463-1-git-send-email-jwm@horde.net>

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

  parent reply	other threads:[~2010-11-07 20:49 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-07 15:44 [Qemu-devel] [PATCH] Overwrite argv to set process title, eliminating 16-character prctl() limit John Morrissey
2010-11-07 18:27 ` Andreas Färber
2010-11-07 19:42   ` [Qemu-devel] " John Morrissey
2010-11-07 20:49 ` Torsten Förtsch [this message]
2010-11-09 19:21   ` John Morrissey
  -- strict thread matches above, loose matches on Subject: below --
2010-11-22 22:26 [Qemu-devel] " John Morrissey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201011072149.28266.torsten.foertsch@gmx.net \
    --to=torsten.foertsch@gmx.net \
    --cc=jwm@horde.net \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.