aboutsummaryrefslogtreecommitdiff
path: root/kernel/proc/proc.py
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/proc/proc.py')
-rw-r--r--kernel/proc/proc.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/kernel/proc/proc.py b/kernel/proc/proc.py
new file mode 100644
index 0000000..11a5f31
--- /dev/null
+++ b/kernel/proc/proc.py
@@ -0,0 +1,38 @@
+import gdb
+
+import weenix
+import weenix.list
+import weenix.proc
+
+
+class ProcCommand(weenix.Command):
+ """proc [<pids...>]
+ Prints information about the listed pids. If no
+ pids are listed the full process tree is printed."""
+
+ def __init__(self):
+ weenix.Command.__init__(self, "proc", gdb.COMMAND_DATA)
+
+ def invoke(self, args, tty):
+ print("invoking...")
+ if (len(args.strip()) == 0):
+ print(weenix.proc.str_proc_tree())
+ else:
+ for pid in args.split():
+ if (pid == "curproc"):
+ print(weenix.proc.curproc())
+ else:
+ print(weenix.proc.lookup(pid))
+
+ def complete(self, line, word):
+ print("completing...")
+ l = map(lambda x: str(x.pid()), weenix.proc.iter())
+ l.append("curproc")
+ l = filter(lambda x: x.startswith(word), l)
+ for used in line.split():
+ l = filter(lambda x: x != used, l)
+ l.sort()
+ return l
+
+
+ProcCommand()