 USING: accessors arrays combinators combinators.smart
 io.encodings.utf8 io.files kernel math math.order math.parser
 memoize sequences sorting.slots splitting splitting.monotonic
-strings io.pathnames calendar ;
+strings io.pathnames calendar words ;
 IN: unix.linux.proc
 
 ! /proc/*

    "stat" proc-pid-path
    proc-first-line
    " " split harvest
    52 "0" pad-tail  ! XXX: Kernel 3.2 doesn't have enough entries
    [ dup string>number [ nip ] when* ] map
    [ pid-stat boa ] input<sequence ;


! Different kernels have fewer fields. Make sure we have enough.
: parse-proc-meminfo ( -- meminfo )
    "/proc/meminfo" utf8 file-lines
    [ " " split harvest second string>number 1024 * ] map
    proc-meminfo "slots" word-prop length f pad-tail
    [ proc-meminfo boa ] input<sequence ;

! All cpu-stat fields are measured in jiffies.
TUPLE: proc-stat
