aboutsummaryrefslogtreecommitdiff
path: root/kernel/proc/proc.c
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/proc/proc.c')
-rw-r--r--kernel/proc/proc.c33
1 files changed, 14 insertions, 19 deletions
diff --git a/kernel/proc/proc.c b/kernel/proc/proc.c
index eab6556..f7878a2 100644
--- a/kernel/proc/proc.c
+++ b/kernel/proc/proc.c
@@ -265,19 +265,21 @@ void proc_cleanup(long status)
// NOT_YET_IMPLEMENTED("PROCS: proc_cleanup");
dbg(DBG_PROC, "proc_cleanup called on proc with pid=%d with exit status=%d\n", curproc->p_pid, status);
-#ifdef __VFS__
+ curproc->p_state = PROC_DEAD;
+
+ // update state and status
+ // if (curthr->kt_cancelled) {
+ // curproc->p_status = curthr->kt_retval;
+ // } else {
+ // }
+ curproc->p_status = status;
+
for (int fd = 0; fd < NFILES; fd++)
{
- if (curproc->p_files[fd])
- {
- fput(curproc->p_files + fd);
- }
+ do_close(fd);
}
- if (curproc->p_cwd)
- {
- vput(&curproc->p_cwd);
- }
-#endif
+ vput(&curproc->p_cwd);
+ vmmap_destroy(&curproc->p_vmmap);
if (curproc->p_pid == PID_INIT)
{
@@ -297,16 +299,8 @@ void proc_cleanup(long status)
// remove & insert to init process
child->p_pproc = proc_initproc;
list_remove(&child->p_child_link);
- list_insert_tail(&curproc->p_pproc->p_children, &child->p_child_link);
+ list_insert_head(&proc_initproc->p_children, &child->p_child_link);
}
-
- // update state and status
- curproc->p_state = PROC_DEAD;
- // if (curthr->kt_cancelled) {
- // curproc->p_status = curthr->kt_retval;
- // } else {
- curproc->p_status = status;
- // }
}
/*
@@ -371,6 +365,7 @@ void proc_kill_all()
p->p_pproc->p_pid != PID_IDLE
)
{
+ // proc_kill(p, curproc->p_status);
proc_kill(p, -1);
}
}