unix.linux.proc: future proof!

db4
John Benediktsson 2014-04-22 07:50:35 -07:00
parent 06912460b4
commit 3dae660d42
1 changed files with 6 additions and 6 deletions

View File

@ -3,7 +3,7 @@
USING: accessors arrays combinators combinators.smart USING: accessors arrays combinators combinators.smart
io.encodings.utf8 io.files kernel math math.order math.parser io.encodings.utf8 io.files kernel math math.order math.parser
memoize sequences sorting.slots splitting splitting.monotonic memoize sequences sorting.slots splitting splitting.monotonic
strings io.pathnames calendar ; strings io.pathnames calendar words ;
IN: unix.linux.proc IN: unix.linux.proc
! /proc/* ! /proc/*
@ -184,10 +184,10 @@ TUPLE: proc-meminfo
! Different kernels have fewer fields. Make sure we have enough. ! Different kernels have fewer fields. Make sure we have enough.
: parse-proc-meminfo ( -- meminfo ) : parse-proc-meminfo ( -- meminfo )
"/proc/meminfo" utf8 file-lines [ "/proc/meminfo" utf8 file-lines
" " split harvest second string>number 1024 * [ " " split harvest second string>number 1024 * ] map
] map proc-meminfo "slots" word-prop length f pad-tail
50 f pad-tail [ proc-meminfo boa ] input<sequence ; [ proc-meminfo boa ] input<sequence ;
! All cpu-stat fields are measured in jiffies. ! All cpu-stat fields are measured in jiffies.
TUPLE: proc-stat TUPLE: proc-stat
@ -331,6 +331,6 @@ TUPLE: pid-stat pid filename state parent-pid group-id session-id terminal#
"stat" proc-pid-path "stat" proc-pid-path
proc-first-line proc-first-line
" " split harvest " " split harvest
52 "0" pad-tail ! XXX: Kernel 3.2 doesn't have enough entries pid-stat "slots" word-prop length "0" pad-tail
[ dup string>number [ nip ] when* ] map [ dup string>number [ nip ] when* ] map
[ pid-stat boa ] input<sequence ; [ pid-stat boa ] input<sequence ;