aboutsummaryrefslogtreecommitdiff
path: root/kernel/proc/proc.c
diff options
context:
space:
mode:
authorsotech117 <michael_foiani@brown.edu>2024-02-20 18:23:50 +0000
committersotech117 <michael_foiani@brown.edu>2024-02-20 18:23:50 +0000
commitd2b13e08f8d6111b7f7e79a47a124fc47dd9433c (patch)
treeec46a99622c40dae1d45ff516699f949193275a2 /kernel/proc/proc.c
parent84aae99b4f2f4997db95b9ea6db2a61f582b51ea (diff)
make tests and fix bugs that the tests caught :)
Diffstat (limited to 'kernel/proc/proc.c')
-rw-r--r--kernel/proc/proc.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/kernel/proc/proc.c b/kernel/proc/proc.c
index 2a7cdba..d0566ec 100644
--- a/kernel/proc/proc.c
+++ b/kernel/proc/proc.c
@@ -181,8 +181,6 @@ proc_t *proc_create(const char *name)
return NULL;
}
- dbg(DBG_PROC, "creating process name=%s & pid =%d\n", name, proc_pid);
-
proc_t *proc = (proc_t *)slab_obj_alloc(proc_allocator);
if (proc == NULL)
{
@@ -219,6 +217,8 @@ proc_t *proc_create(const char *name)
list_insert_tail(&curproc->p_children, &proc->p_child_link);
list_insert_tail(&proc_list, &proc->p_list_link);
+ dbg(DBG_PROC, "SUCESSFULLY created PROCESS name=%s & pid =%d\n", name, proc_pid);
+
return proc;
}
@@ -325,12 +325,11 @@ void proc_kill_all()
{
// NOT_YET_IMPLEMENTED("PROCS: proc_kill_all");
- // TODO: consider children on children
- list_iterate(&proc_initproc->p_children, thr, kthread_t, kt_plink)
+ list_iterate(&proc_list, p, proc_t, p_list_link)
{
- if((proc_t *) &thr->kt_proc != curproc)
+ if (p->p_pid != curproc->p_pid && p->p_pid != PID_IDLE)
{
- kthread_cancel(thr, 0);
+ proc_kill(p, 0);
}
}
@@ -435,8 +434,10 @@ pid_t do_waitpid(pid_t pid, int *status, int options)
if (status != NULL)
{
+ dbg(DBG_PROC, "setting status to %d\n", child->p_status);
*status = child->p_status;
}
+ list_remove(&child->p_child_link);
proc_destroy(child);
dbg(DBG_PROC, "exited child pid=%d\n", child->p_pid);
@@ -459,6 +460,7 @@ pid_t do_waitpid(pid_t pid, int *status, int options)
dbg(DBG_PROC, "found a dead thread with pid=%d\n", child->p_pid);
if (status != NULL)
{
+ dbg(DBG_PROC, "setting status to %d\n", child->p_status);
*status = child->p_status;
}
int child_pid = child->p_pid;
@@ -487,7 +489,7 @@ void do_exit(long status)
{
// NOT_YET_IMPLEMENTED("PROCS: do_exit");
- dbg(DBG_PROC, "proc exiting with pid=%d", curproc->p_pid);
+ dbg(DBG_PROC, "proc exiting with pid=%d and status=%ld\n", curproc->p_pid, status);
kthread_exit((void *)status);
}