Skip to content
This repository was archived by the owner on Jul 21, 2025. It is now read-only.

Commit df09553

Browse files
authored
Update process.c
Made so that process_destroy() actually can destroy a process
1 parent 5cc038a commit df09553

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

kernel/core/process.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,22 @@ Process* process_create(char* name, int ppid, Domain domain, u32 entry, u32 stac
8484
}
8585

8686
void process_destroy(Process* proc) {
87-
// TODO: Make this actually work
87+
// Remove from process table
88+
processes[proc->pid] = NULL;
89+
90+
// Mark as terminated
91+
proc->proc_state = TERMINATED;
92+
93+
// Free kernel stack
94+
free((void*)(proc->ksp - (KERNEL_STACK_SIZE - sizeof(cpu_state_t))));
95+
96+
// Free user stack
97+
free((void*)(proc->usp - (KERNEL_STACK_SIZE - sizeof(cpu_state_t))));
98+
99+
// Free the process struct itself
100+
free(proc);
101+
102+
// NOTE: No file descriptor cleanup, and parent/child handling is manual
88103

89104
}
90105

0 commit comments

Comments
 (0)