diff options
author | dzwdz | 2022-04-15 23:42:43 +0200 |
---|---|---|
committer | dzwdz | 2022-04-15 23:42:43 +0200 |
commit | 42e4b941b70499f5cf10f41126af1634821d72d5 (patch) | |
tree | 6b56775263837b7883b7a05a7603bc59274ce05d /src/kernel/proc.c | |
parent | 26849aa2b3f49cbad8be4688800667e2d89aa5db (diff) |
kernel/vfs: don't hang on orphaned vfs calls
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r-- | src/kernel/proc.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c index ad2a72b..9779478 100644 --- a/src/kernel/proc.c +++ b/src/kernel/proc.c @@ -54,6 +54,9 @@ struct process *process_fork(struct process *parent) { parent->handled_req = NULL; // TODO control this with a flag + if (child->controlled) + child->controlled->potential_handlers++; + child->id = next_pid++; return child; @@ -189,9 +192,21 @@ void process_transition(struct process *p, enum process_state state) { void process_kill(struct process *proc, int ret) { // TODO kill children + if (proc->controlled) { + proc->controlled->potential_handlers--; + if (proc->controlled->potential_handlers == 0) { + // orphaned + struct process *q = proc->controlled->queue; + while (q) { + assert(q->state == PS_WAITS4FS); + struct process *q2 = q->waits4fs.queue_next; + vfs_request_cancel(&q->waits4fs.req, ret); + q = q2; + } + } + } if (proc->handled_req) { - regs_savereturn(&proc->handled_req->caller->regs, -1); - process_transition(proc->handled_req->caller, PS_RUNNING); + vfs_request_cancel(proc->handled_req, ret); } process_transition(proc, PS_DEAD); proc->death_msg = ret; |