git: 3c47f0a54d04 - stable/13 - Add curproc_sigkilled()

From: Konstantin Belousov <kib_at_FreeBSD.org>
Date: Sun, 10 Oct 2021 09:24:26 UTC
The branch stable/13 has been updated by kib:

URL: https://cgit.FreeBSD.org/src/commit/?id=3c47f0a54d042189cba0e292420ae7dc384ec396

commit 3c47f0a54d042189cba0e292420ae7dc384ec396
Author:     Konstantin Belousov <kib@FreeBSD.org>
AuthorDate: 2021-10-05 05:08:51 +0000
Commit:     Konstantin Belousov <kib@FreeBSD.org>
CommitDate: 2021-10-10 09:22:58 +0000

    Add curproc_sigkilled()
    
    (cherry picked from commit 244ab56611c15e737b76cb3950c32e37b67c26fc)
---
 sys/kern/kern_sig.c | 23 +++++++++++++++++++++++
 sys/sys/proc.h      |  1 +
 2 files changed, 24 insertions(+)

diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 38261118897f..7a1fd0bab917 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -3315,6 +3315,29 @@ sig_intr(void)
 	return (ret);
 }
 
+bool
+curproc_sigkilled(void)
+{
+	struct thread *td;
+	struct proc *p;
+	struct sigacts *ps;
+	bool res;
+
+	td = curthread;
+	if ((td->td_flags & TDF_NEEDSIGCHK) == 0)
+		return (false);
+
+	p = td->td_proc;
+	PROC_LOCK(p);
+	ps = p->p_sigacts;
+	mtx_lock(&ps->ps_mtx);
+	res = SIGISMEMBER(td->td_sigqueue.sq_signals, SIGKILL) ||
+	    SIGISMEMBER(p->p_sigqueue.sq_signals, SIGKILL);
+	mtx_unlock(&ps->ps_mtx);
+	PROC_UNLOCK(p);
+	return (res);
+}
+
 void
 proc_wkilled(struct proc *p)
 {
diff --git a/sys/sys/proc.h b/sys/sys/proc.h
index 64007513f5b6..67dc32dbaa03 100644
--- a/sys/sys/proc.h
+++ b/sys/sys/proc.h
@@ -1148,6 +1148,7 @@ int	cpu_idle_wakeup(int);
 extern	void (*cpu_idle_hook)(sbintime_t);	/* Hook to machdep CPU idler. */
 void	cpu_switch(struct thread *, struct thread *, struct mtx *);
 void	cpu_throw(struct thread *, struct thread *) __dead2;
+bool	curproc_sigkilled(void);
 void	userret(struct thread *, struct trapframe *);
 
 void	cpu_exit(struct thread *);