Skip to content

Commit 5dd14a8

Browse files
committed
sched: prototype for thread cleanup in waitpid()
1 parent 99ab26e commit 5dd14a8

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/include/kernel/sched.h

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ int schedException(pid_t, pid_t);
120120
void terminateThread(Thread *, int, bool);
121121
void schedSleepTimer();
122122
Thread *getKernelThread();
123+
void threadCleanup(Thread *);
123124

124125
// these functions are exposed as system calls, but some will need to take
125126
// the thread as an argument from the system call handler - the actual user

src/sched/waitpid.c

+6-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,12 @@ static pid_t processStatus(Process *p, int *status) {
2727
if((!t->clean) && (t->status == THREAD_ZOMBIE)) {
2828
t->clean = true;
2929
*status = t->exitStatus;
30-
return t->tid;
30+
pid_t pid = t->tid;
31+
32+
// free the thread structure
33+
threadCleanup(t);
34+
35+
return pid;
3136
}
3237
}
3338

0 commit comments

Comments
 (0)