mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 16:17:45 +00:00
Kernel: Make sure threads which don't do any syscalls are terminated
Steps to reproduce: $ cat loop.c int main() { for (;;); } $ gcc -o loop loop.c $ ./loop Terminating this process wasn't previously possible because we only checked whether the thread should be terminated on syscall exit.
This commit is contained in:
parent
c980a51776
commit
3c3a1726df
3 changed files with 20 additions and 0 deletions
|
@ -192,6 +192,13 @@ bool Scheduler::pick_next()
|
|||
|
||||
ScopedSpinLock lock(g_scheduler_lock);
|
||||
|
||||
auto current_thread = Thread::current();
|
||||
if (current_thread->should_die() && current_thread->may_die_immediately()) {
|
||||
// Ordinarily the thread would die on syscall exit, however if the thread
|
||||
// doesn't perform any syscalls we still need to mark it for termination here.
|
||||
current_thread->set_state(Thread::Dying);
|
||||
}
|
||||
|
||||
if constexpr (SCHEDULER_RUNNABLE_DEBUG) {
|
||||
dump_thread_list();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue