Skip to main content

linux_identity_from_stat

Function linux_identity_from_stat 

Source
pub fn linux_identity_from_stat(
    stat: &str,
) -> Result<Option<String>, MalformedStat>
Expand description

What: The birth identity in one /proc/<pid>/stat text, or nothing for an exited process. Result<Option<String>, MalformedStat> is “an identity, nothing, or a malformed record”. Why: The incumbent cuts after the last ) (the command name may hold spaces and )), skips ) , trims, splits on single spaces, treats states Z and X as exited (a zombie under a container init that never reaps keeps its PID forever), and answers linux: plus the start tick. An empty start field is malformed.

In TS you’d write (pseudocode):

function linuxIdentityFromStat(stat: string): string | typeof ABSENT; // throws when malformed