diff --git a/src/bin/LSPS.hx b/src/bin/LSPS.hx new file mode 100644 index 0000000..bd7be6e --- /dev/null +++ b/src/bin/LSPS.hx @@ -0,0 +1,21 @@ +package bin; + +import kernel.ps.ProcessManager; +import kernel.ps.ProcessHandle; +import kernel.ps.Process; + +class LSPS implements Process { + public function new() {} + + public function run(handle:ProcessHandle) { + var pids = ProcessManager.listProcesses(); + + handle.writeLine('Count: ${pids.length}'); + + for (pid in pids) { + handle.writeLine('${pid}'); + } + + handle.close(); + } +} \ No newline at end of file diff --git a/src/kernel/binstore/BinStore.hx b/src/kernel/binstore/BinStore.hx index d100983..a128053 100644 --- a/src/kernel/binstore/BinStore.hx +++ b/src/kernel/binstore/BinStore.hx @@ -1,5 +1,6 @@ package kernel.binstore; +import bin.LSPS; import bin.Turtle; import bin.Terminal; import haxe.ds.ReadOnlyArray; @@ -21,7 +22,8 @@ class BinStore { {c: Net, name: "Net", aliases: ["net"]}, {c: Redstone, name: "Redstone", aliases: ["redstone","rs"]}, {c: Terminal, name: "Terminal", aliases: ["terminal","term"]}, - {c: Turtle, name: "Turtle", aliases: ["turtle"]} + {c: Turtle, name: "Turtle", aliases: ["turtle"]}, + {c: LSPS, name: "PM", aliases: ["lsps"]} ]; @:allow(kernel.Init) diff --git a/src/kernel/ps/ProcessManager.hx b/src/kernel/ps/ProcessManager.hx index 77500f8..1e71d1a 100644 --- a/src/kernel/ps/ProcessManager.hx +++ b/src/kernel/ps/ProcessManager.hx @@ -34,4 +34,8 @@ class ProcessManager { private static function removeProcess(pid:PID):Void { processList.remove(pid); } + + public static function listProcesses():Array { + return [for (pid in processList.keys()) pid]; + } }