From 49c394a9708052882cb296a2d5ed4bf95e662456 Mon Sep 17 00:00:00 2001 From: Konstantin Belousov Date: Wed, 10 Aug 2016 13:47:12 +0000 Subject: [PATCH] Re-schedule signals after kthread exits, since apparently there are processes which combine kernel and non-kernel threads, e.g. nfsd. For such processes, termination of a kthread must recheck signal delivery among other threads according to masks. Reported and tested by: pho Sponsored by: The FreeBSD Foundation MFC after: 1 week --- sys/kern/kern_kthread.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sys/kern/kern_kthread.c b/sys/kern/kern_kthread.c index 72c01f0f0d40..04f3423fb958 100644 --- a/sys/kern/kern_kthread.c +++ b/sys/kern/kern_kthread.c @@ -320,11 +320,13 @@ void kthread_exit(void) { struct proc *p; + struct thread *td; - p = curthread->td_proc; + td = curthread; + p = td->td_proc; /* A module may be waiting for us to exit. */ - wakeup(curthread); + wakeup(td); /* * The last exiting thread in a kernel process must tear down @@ -337,9 +339,10 @@ kthread_exit(void) rw_wunlock(&tidhash_lock); kproc_exit(0); } - LIST_REMOVE(curthread, td_hash); + LIST_REMOVE(td, td_hash); rw_wunlock(&tidhash_lock); - umtx_thread_exit(curthread); + umtx_thread_exit(td); + tdsigcleanup(td); PROC_SLOCK(p); thread_exit(); }