From: claudio Date: Wed, 9 Oct 2024 08:39:49 +0000 (+0000) Subject: Convert prsignal() into a real function X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=2d5a42141c9ba258f3db4b3f809b4ec766927ba2;p=openbsd 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@ --- 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 diff --git a/sys/sys/signalvar.h b/sys/sys/signalvar.h index 3912d92623b..a8c6168f7ef 100644 --- a/sys/sys/signalvar.h +++ b/sys/sys/signalvar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: signalvar.h,v 1.54 2022/05/13 15:32:00 claudio Exp $ */ +/* $OpenBSD: signalvar.h,v 1.55 2024/10/09 08:39:49 claudio Exp $ */ /* $NetBSD: signalvar.h,v 1.17 1996/04/22 01:23:31 christos Exp $ */ /* @@ -114,7 +114,7 @@ void pgsigio(struct sigio_ref *sir, int sig, int checkctty); void pgsignal(struct pgrp *pgrp, int sig, int checkctty); void psignal(struct proc *p, int sig); void ptsignal(struct proc *p, int sig, enum signal_type type); -#define prsignal(pr,sig) ptsignal((pr)->ps_mainproc, (sig), SPROCESS) +void prsignal(struct process *pr, int sig); void trapsignal(struct proc *p, int sig, u_long code, int type, union sigval val); __dead void sigexit(struct proc *, int);