Skip to content

Commit

Permalink
tools.ps: Add a simple Linux-only ps clone.
Browse files Browse the repository at this point in the history
  • Loading branch information
erg committed Feb 4, 2012
1 parent 1280f4d commit 1fa6818
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 0 deletions.
1 change: 1 addition & 0 deletions basis/tools/ps/authors.txt
@@ -0,0 +1 @@
Doug Coleman
1 change: 1 addition & 0 deletions basis/tools/ps/platforms.txt
@@ -0,0 +1 @@
linux
4 changes: 4 additions & 0 deletions basis/tools/ps/ps-tests.factor
@@ -0,0 +1,4 @@
USING: tools.ps tools.test ;
IN: tools.ps.tests

{ } [ ps. ] unit-test
23 changes: 23 additions & 0 deletions basis/tools/ps/ps.factor
@@ -0,0 +1,23 @@
! Copyright (C) 2012 Doug Coleman.
! See http://factorcode.org/license.txt for BSD license.
USING: assocs io.directories io.encodings.utf8 io.files
io.pathnames kernel math.parser prettyprint sequences splitting
unicode.categories ;
IN: tools.ps

: ps-comm ( path -- string )
"/comm" append utf8 file-contents "\0" split " " join
[ blank? ] trim "[" "]" surround ;

: ps-cmdline ( path -- path string )
dup "/cmdline" append utf8 file-contents
[ dup ps-comm ] [ "\0" split " " join ] if-empty ;

: ps ( -- assoc )
"/proc" [
"." directory-files [ file-name string>number ] filter
[ ps-cmdline ] { } map>assoc
] with-directory ;

: ps. ( -- )
ps simple-table. ;
1 change: 1 addition & 0 deletions basis/tools/ps/summary.txt
@@ -0,0 +1 @@
A basic ps utility for Linux.

0 comments on commit 1fa6818

Please sign in to comment.