To prepare for caching a sigqueue per task, implement a dedicated function
to flush the sigqueue of the exiting task.

No functional change.

Signed-off-by: Thomas Gleixner <t...@linutronix.de>
---
 include/linux/signal.h |    1 +
 kernel/exit.c          |    3 +--
 kernel/signal.c        |    9 +++++++++
 3 files changed, 11 insertions(+), 2 deletions(-)

--- a/include/linux/signal.h
+++ b/include/linux/signal.h
@@ -265,6 +265,7 @@ static inline void init_sigpending(struc
 }
 
 extern void flush_sigqueue(struct sigpending *queue);
+extern void exit_task_sighand(struct task_struct *tsk);
 
 /* Test if 'sig' is valid signal. Use this instead of testing _NSIG directly */
 static inline int valid_signal(unsigned long sig)
--- a/kernel/exit.c
+++ b/kernel/exit.c
@@ -152,8 +152,7 @@ static void __exit_signal(struct task_st
         * Do this under ->siglock, we can race with another thread
         * doing sigqueue_free() if we have SIGQUEUE_PREALLOC signals.
         */
-       flush_sigqueue(&tsk->pending);
-       tsk->sighand = NULL;
+       exit_task_sighand(tsk);
        spin_unlock(&sighand->siglock);
 
        __cleanup_sighand(sighand);
--- a/kernel/signal.c
+++ b/kernel/signal.c
@@ -471,6 +471,15 @@ void flush_sigqueue(struct sigpending *q
 }
 
 /*
+ * Called from __exit_signal. Flush tsk->pending and clear tsk->sighand.
+ */
+void exit_task_sighand(struct task_struct *tsk)
+{
+       flush_sigqueue(&tsk->pending);
+       tsk->sighand = NULL;
+}
+
+/*
  * Flush all pending signals for this kthread.
  */
 void flush_signals(struct task_struct *t)

Reply via email to