library: correct 'vectorized' string logic, <PIDS> api

The commit referenced below addressed (some) anomalies
surrounding 'strv' pointers. However, there remained a
couple quirks involving a potential NULL return value.

Any NULL values returned from the old library readproc
guys would cause no real harm for newlib. But they did
produce the misleading "[ duplicate ENUM_ID ]" result.

The following all represent potential NULL results and
suggest shortcomings in testing of that earlier patch.

. kernel threads do not have cgroup, cmdline & environ
. even if present environ could require root to access

So, this patch reverts a portion of the earlier commit
and ensures when some vectored string is not available
a traditional dash ('-') is the 'strv' returned value.

[ and we'll also correct one typo in the header file ]

Reference(s):
. eliminated a final potential NULL, <PIDS> api
commit 09503dc597

Signed-off-by: Jim Warner <james.warner@comcast.net>
This commit is contained in:
Jim Warner
2019-04-25 00:00:00 -05:00
committed by Craig Small
parent 30e27d48e9
commit a9bfb186eb
4 changed files with 43 additions and 27 deletions

View File

@ -132,7 +132,7 @@ enum pids_item {
PIDS_TICS_USER, // ull_int stat: utime
PIDS_TICS_USER_C, // ull_int stat: utime + cutime
PIDS_TIME_ALL, // ull_int [ derived from (utime + stime) / hertz ]
PIDS_TIME_ELAPSED, // ull_int [ derived from /proc/uptime - (starttime / hertz) }
PIDS_TIME_ELAPSED, // ull_int [ derived from /proc/uptime - (starttime / hertz) ]
PIDS_TIME_START, // ull_int stat: starttime
PIDS_TTY, // s_int stat: tty_nr
PIDS_TTY_NAME, // str [ derived from TTY ]