From 5815adca7db48c158397c7efc102bd9ba32119c8 Mon Sep 17 00:00:00 2001 From: "K. Lange" Date: Fri, 2 Sep 2022 13:15:24 +0900 Subject: [PATCH] procfs: RUNNING processes should have state R --- kernel/vfs/procfs.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/kernel/vfs/procfs.c b/kernel/vfs/procfs.c index 78f8a0da..2d28d949 100644 --- a/kernel/vfs/procfs.c +++ b/kernel/vfs/procfs.c @@ -151,9 +151,17 @@ static void proc_status_func(fs_node_t *node) { return; } - char state = (proc->flags & PROC_FLAG_FINISHED) ? 'Z' : - ((proc->flags & PROC_FLAG_SUSPENDED) ? 'T' : - (process_is_ready(proc) ? 'R' : 'S')); + char state = 'S'; + + /* Base state */ + if ((proc->flags & PROC_FLAG_RUNNING) || process_is_ready(proc)) { + state = 'R'; /* Running or runnable */ + } else if ((proc->flags & PROC_FLAG_FINISHED)) { + state = 'Z'; /* Zombie - exited but not yet reaped */ + } else if ((proc->flags & PROC_FLAG_SUSPENDED)) { + state = 'T'; /* Stopped; TODO can we differentiate stopped tracees correctly? */ + } + char * name = proc->name + strlen(proc->name) - 1; while (1) {