summaryrefslogtreecommitdiff
path: root/sys/kern
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2024-10-09 08:39:50 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2024-10-09 08:39:50 +0000
commite25a2fd728af854333ee86850722c21c8124edb2 (patch)
tree65d9948b99e8b96c6890e4f2255759761ab66c58 /sys/kern
parent9639a8aabd74fbb10b3fc377dbaac5b19c006e8d (diff)
Convert prsignal() into a real function
Also do not use ps_mainproc as the thread the signal is send to. Sending a signal to ps_mainproc may not work reliably if it already exited. Use TAILQ_FIRST(&pr->ps_threads) instead but first check that the process has not yet entered exit1(). OK mpi@
Diffstat (limited to 'sys/kern')
-rw-r--r--sys/kern/kern_sig.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/sys/kern/kern_sig.c b/sys/kern/kern_sig.c
index 8f8ab6405f6..ae226ed639b 100644
--- a/sys/kern/kern_sig.c
+++ b/sys/kern/kern_sig.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_sig.c,v 1.339 2024/10/01 08:28:34 claudio Exp $ */
+/* $OpenBSD: kern_sig.c,v 1.340 2024/10/09 08:39:49 claudio Exp $ */
/* $NetBSD: kern_sig.c,v 1.54 1996/04/22 01:38:32 christos Exp $ */
/*
@@ -901,6 +901,16 @@ psignal(struct proc *p, int signum)
ptsignal(p, signum, SPROCESS);
}
+void
+prsignal(struct process *pr, int signum)
+{
+ /* Ignore signal if the target process is exiting */
+ if (pr->ps_flags & PS_EXITING) {
+ return;
+ }
+ ptsignal(TAILQ_FIRST(&pr->ps_threads), signum, SPROCESS);
+}
+
/*
* type = SPROCESS process signal, can be diverted (sigwait())
* type = STHREAD thread signal, but should be propagated if unhandled