linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thorsten Glaser <tg@mirbsd.de>
To: Alexey Dobriyan <adobriyan@gmail.com>, linux-fsdevel@vger.kernel.org
Cc: 1024811@bugs.debian.org
Subject: Re: Bug#1024811: linux: /proc/[pid]/stat unparsable
Date: Thu, 22 Dec 2022 01:53:13 +0100 (CET)	[thread overview]
Message-ID: <d1f6877d-a084-2099-5764-979ee163eace@evolvis.org> (raw)
In-Reply-To: <Y4Hshbyk9TEsSQsm@p183>

On Sat, 26 Nov 2022, Alexey Dobriyan wrote:

>/proc never escaped "comm" field of /proc/*/stat.

Yes, that’s precisely the bug.

>To parse /proc/*/stat reliably, search for '(' from the beginning, then
>for ')' backwards. Everything in between parenthesis is "comm".

That’s not guaranteed to stay reliable: fields can be, and have
been in the past, added, and new %s fields will break this. Do
not rely on it either.

>Everything else are numbers separated by spaces.

Currently, yes.

But the field is *clearly* documented as intended to be
parsable by scanf(3), which splits on white space. So the
Linux kernel MUST encode embedded whitespace so the
documented(!) access method works.

bye,
//mirabilos
-- 
15:41⎜<Lo-lan-do:#fusionforge> Somebody write a testsuite for helloworld :-)

  parent reply	other threads:[~2022-12-22  0:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <166939644927.12906.17757536147994071219.reportbug@x61w.mirbsd.org>
2022-11-25 17:24 ` Bug#1024811: linux: /proc/[pid]/stat unparsable Thorsten Glaser
     [not found] ` <Y4Hshbyk9TEsSQsm@p183>
2022-12-22  0:53   ` Thorsten Glaser [this message]
2022-12-22 13:45     ` Donald Buczek
2022-12-22 20:28       ` Thorsten Glaser
2022-12-23  8:42         ` Donald Buczek
2022-12-23  8:49           ` Thorsten Glaser
2022-12-23  9:11             ` Donald Buczek

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=d1f6877d-a084-2099-5764-979ee163eace@evolvis.org \
    --to=tg@mirbsd.de \
    --cc=1024811@bugs.debian.org \
    --cc=adobriyan@gmail.com \
    --cc=linux-fsdevel@vger.kernel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).