When the leader thread exits, it doesn't notify other threads. So even if other threads are woken up or scheduled, they will continue to run instead of exiting.
One solution is to send signal to other threads which belong to the same process, and call exit function when handling the signal.
if current_task.is_leader() {
loop {
let mut all_exited = true;
for task in process.tasks.lock().deref() {
if !task.is_leader() && task.state() != TaskState::Exited {
all_exited = false;
send_signal_to_thread(task.id().as_u64() as isize, SignalNo::SIGKILL as isize)
.unwrap();
}
}
if !all_exited {
yield_now();
} else {
break;
}
}
....
}
When the leader thread exits, it doesn't notify other threads. So even if other threads are woken up or scheduled, they will continue to run instead of exiting.
One solution is to send signal to other threads which belong to the same process, and call exit function when handling the signal.