All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Suzuki K. Poulose" <Suzuki.Poulose@arm.com>
To: Steven Stewart-Gallus <sstewartgallus00@mylangara.bc.ca>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: How can I parse the command name from /proc/<pid>/stat?
Date: Fri, 05 Dec 2014 10:34:51 +0000	[thread overview]
Message-ID: <54818A4B.60100@arm.com> (raw)
In-Reply-To: <fc15da367389.5480b999@langara.bc.ca>

On 04/12/14 19:44, Steven Stewart-Gallus wrote:
> Hello,
>
> Given an evil hacker trying to confuse process monitors that might use such
> strange process names as 'pause) R 0 0 (foo' how can I correctly parse the
> command name from /proc/<pid>/stat? Maybe I should just use /proc/<pid>/status?
> Maybe there should be some documentation written on the issue? I just wanted to
> send an email off to check if I was missing anything before writing a few small
> additions to the documentation or filing a bug report. procps-ng seems to use an
> ugly hack that involves knowing the limits on the size of a possible command
> name that I'm not actually sure works totally correctly.

You can do something like :

cmd_start = strchr(stat_buf, '(');
cmd_end = strrchr(stat_buf, ')');

Cheers
Suzuki


>
> Thank you,
> Steven Stewart-Gallus
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>
>



  reply	other threads:[~2014-12-05 10:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-04 19:44 How can I parse the command name from /proc/<pid>/stat? Steven Stewart-Gallus
2014-12-05 10:34 ` Suzuki K. Poulose [this message]
2014-12-06 23:04   ` Steven Stewart-Gallus

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=54818A4B.60100@arm.com \
    --to=suzuki.poulose@arm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sstewartgallus00@mylangara.bc.ca \
    /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.