From c63f340d90800895f007de64b7d2d14624263331 Mon Sep 17 00:00:00 2001 From: nthnluu Date: Sun, 28 Jan 2024 21:20:27 -0500 Subject: Created student weenix repository --- kernel/proc/proc.py | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 kernel/proc/proc.py (limited to 'kernel/proc/proc.py') 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 [] + 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() -- cgit v1.2.3-70-g09d2