pub fn parse_stat_ticks(stat: &str) -> Option<u64>Expand description
Sum of utime + stime (fields 14 and 15, 1-indexed) from a /proc/<pid>/stat line.
The classic parsing trap: field 2 is comm, the executable name in parentheses, and it can
contain spaces AND parentheses — e.g. a thread named (my proc) worker yields
1234 ((my proc) worker) S .... Splitting the whole line on whitespace therefore mis-counts
fields. The robust fix the kernel itself documents: comm is wrapped in the FIRST ( and
the LAST ), so slice from after the last ) and field-count the tail. After that ) the
fields are fixed-position and space-separated, with state first — so utime/stime are the
12th and 13th tokens of the tail (stat fields 14/15 = tail positions 12/13, since the tail
begins at field 3 state).