summaryrefslogtreecommitdiff
path: root/src/kernel/proc.c
diff options
context:
space:
mode:
authordzwdz2022-05-02 19:25:02 +0200
committerdzwdz2022-05-02 19:25:02 +0200
commit577ed9e01a83c13bf151b5137e6fe1eace1c4f7c (patch)
tree750dd8a3536ce70d817e6920c89042ee94899a29 /src/kernel/proc.c
parentd9dc6a0c4c5047c3789a16ef623eeff7c240f5a9 (diff)
syscalls: fork() noreap flag
Diffstat (limited to 'src/kernel/proc.c')
-rw-r--r--src/kernel/proc.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/kernel/proc.c b/src/kernel/proc.c
index 838d520..4dfee15 100644
--- a/src/kernel/proc.c
+++ b/src/kernel/proc.c
@@ -6,6 +6,7 @@
#include <kernel/proc.h>
#include <kernel/vfs/mount.h>
#include <shared/mem.h>
+#include <shared/syscalls.h>
#include <stdint.h>
struct process *process_first;
@@ -49,7 +50,7 @@ struct process *process_seed(struct kmain_info *info) {
return process_first;
}
-struct process *process_fork(struct process *parent) {
+struct process *process_fork(struct process *parent, int flags) {
struct process *child = kmalloc(sizeof *child);
memcpy(child, parent, sizeof *child);
@@ -58,6 +59,7 @@ struct process *process_fork(struct process *parent) {
child->child = NULL;
child->parent = parent;
parent->child = child;
+ child->noreap = (flags & FORK_NOREAP) > 0;
parent->handled_req = NULL; // TODO control this with a flag
@@ -325,7 +327,7 @@ int process_try2collect(struct process *dead) {
assert(dead->state == PS_DEAD);
- if (!parent) {
+ if (!parent || dead->noreap) {
process_transition(dead, PS_DEADER);
return -1;
}