tools.ps: Fix ps tool for linux < 3.
parent
0fb3b968ed
commit
fd2803a916
|
@ -5,13 +5,24 @@ io.pathnames kernel math.parser prettyprint sequences splitting
|
|||
unicode.categories ;
|
||||
IN: tools.ps
|
||||
|
||||
! Only in Linux 3
|
||||
: ps-comm ( path -- string )
|
||||
"/comm" append utf8 file-contents "\0" split " " join
|
||||
[ blank? ] trim "[" "]" surround ;
|
||||
|
||||
: parse-stat ( string -- program-name )
|
||||
" " split
|
||||
second
|
||||
[ CHAR: ( = ] trim-head
|
||||
[ CHAR: ) = ] trim-tail
|
||||
"[" "]" surround ;
|
||||
|
||||
: ps-stat ( path -- string )
|
||||
"/stat" append utf8 file-contents parse-stat ;
|
||||
|
||||
: ps-cmdline ( path -- path string )
|
||||
dup "/cmdline" append utf8 file-contents
|
||||
[ dup ps-comm ] [ "\0" split " " join ] if-empty ;
|
||||
[ dup ps-stat ] [ "\0" split " " join ] if-empty ;
|
||||
|
||||
: ps ( -- assoc )
|
||||
"/proc" [
|
||||
|
|
Loading…
Reference in New Issue