forked from factor/factor
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tools.ps: Add a simple Linux-only ps clone.
- Loading branch information
Showing
5 changed files
with
30 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
Doug Coleman |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
linux |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
USING: tools.ps tools.test ; | ||
IN: tools.ps.tests | ||
|
||
{ } [ ps. ] unit-test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
A basic ps utility for Linux. |