Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: When the leader thread exits, other threads don't exit immediately #23

Closed
Azure-stars opened this issue Aug 5, 2024 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@Azure-stars
Copy link
Contributor

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;
          }
      }
     ....
}
@Azure-stars
Copy link
Contributor Author

commit: Starry-OS/axprocess@4cd862b

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Done
Development

No branches or pull requests

1 participant