[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#1024811: linux: /proc/[pid]/stat unparsable



On 12/23/22 09:49, Thorsten Glaser wrote:
Donald Buczek dixit:

To be fair, this daemon doesn't use /proc/pid/stat for that, but /proc/pid/comm

Yes, and that’s proper. The field in /proc/pid/stat is size-limited
and so not necessarily distinct.

No, it is the process name itself, which is size limited, so in this regard it doesn't make a difference if you read it from /proc/pid/stat or /proc/pid/comm.

As /proc/pid/stat is also used in many places, it could as well use
that to avoid code duplication or reuse data already read from the
other source.

No, because the data in /stat is incomplete *and* anything using
it that would be affected by escaping was already broken.

"Incomplete" because if truncation?

The usage in my example is not already broken. Truncation doesn't happen, because the process name used is the fixed string "mxqd reaper".

A process name is limited to 15 characters. The limit is already in force when you use PR_SET_NAME, so there is no truncation when you read it back from procfs.

D.


bye,
//mirabilos

--
Donald Buczek
buczek@molgen.mpg.de
Tel: +49 30 8413 1433


Reply to: