[Toybox] Another ps question (about -o F)

Rob Landley rob at landley.net
Sat Oct 17 17:36:25 PDT 2015


Userspace sees process flags in /proc/self/stat field 9, but the PF_
macros to interpret them are only in the kernel include/linux/sched.h
_not_ in the include/uapi/linux/sched.h that winds up in /usr/include.

Posix, of course, says that these are "process flags" and they should be
in octal (because nothing else in ps is) but doesn't mention any
specific flag values to expect or what they would mean.

The procps one cherry picks exactly two values, "have we forked but not
execed" and "have we used super-user privileges", and arbitrarily shifts
them 12 bits to the right because of course they do. So 1 means forked
but not execed, 4 means used superuser privs, and that's it, the other
25 bits exported to userspace are ignored (filtered out).

The procps behavior is so useless that -y filters the "F" field out to
make space for rss while leaving room for cmd at 80 columns.

I'm currently mirroring what procps does for "F" just to match their
output, but my help text says I'm exporting the full bits from the
kernel's include/linux/sched.h. I'm not sure which one to fix. (I'm also
tempted to export it as hex, which would currently make zero diference
because 1+4 is the same in hex, octal, and decimal.)

Opinions?

Rob

 1445128585.0


More information about the Toybox mailing list