linux-sysprog · intermediate · ~15 min
Extract a labelled field from /proc text.
Given the text of a /proc/<pid>/status file, implement long parse_vmrss_kb(const char *status) returning the VmRSS value in kB (the number after VmRSS:), or -1 if absent.
#include <string.h>
#include <stdlib.h>
long parse_vmrss_kb(const char *status) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.