From: Ricardo Branco Subject: Add POSIX psiginfo(3) call To: tech@openbsd.org Date: Wed, 16 Apr 2025 10:18:54 +0200 For now use the same implementation used by NetBSD & DragonflyBSD. Attached patch. Best, Ricardo diff --git include/signal.h include/signal.h index 07982bd75a1..7506ef0fbe7 100644 --- include/signal.h +++ include/signal.h @@ -132,6 +132,7 @@ int thrkill(pid_t _tid, int _signum, void *_tcb); int sigwait(const sigset_t *__restrict, int *__restrict); #endif #if __BSD_VISIBLE || __POSIX_VISIBLE >= 200809 +void psiginfo(const siginfo_t *, const char *); void psignal(unsigned int, const char *); #endif #endif /* __BSD_VISIBLE || __POSIX_VISIBLE || __XPG_VISIBLE */ diff --git lib/libc/gen/psignal.3 lib/libc/gen/psignal.3 index 3fd2ebbf7bf..015e968a107 100644 --- lib/libc/gen/psignal.3 +++ lib/libc/gen/psignal.3 @@ -27,11 +27,12 @@ .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" -.Dd $Mdocdate: May 16 2019 $ +.Dd $Mdocdate: Apr 16 2025 $ .Dt PSIGNAL 3 .Os .Sh NAME .Nm psignal , +.Nm psiginfo , .Nm sys_siglist , .Nm sys_signame .Nd system signal messages @@ -39,6 +40,7 @@ .In signal.h .Ft void .Fn psignal "unsigned int sig" "const char *s" +.Fn psiginfo "const siginfo_t *si" "const char *s" .Vt extern char *sys_siglist[]; .Vt extern char *sys_signame[]; .Sh DESCRIPTION @@ -64,6 +66,16 @@ the string .Dq Unknown signal is produced. .Pp +The +.Fn psiginfo +function is similar to +.Fn psignal , +except that the signal number information is taken from the +.Fa si +argument which is a +.Vt siginfo_t +structure. +.Pp The message strings can be accessed directly using the external array .Va sys_siglist , indexed by recognized signal numbers. @@ -87,6 +99,13 @@ The .Fn psignal function appeared in .Bx 4.2 . +The +.Fn psiginfo +function appeared in +.Fx 15.0 , +.Nx 6.0 , +and +.Dx 4.1 . .Sh CAVEATS On systems other than .Ox , diff --git lib/libc/gen/psignal.c lib/libc/gen/psignal.c index dca921d5a5a..ee70d8c95cc 100644 --- lib/libc/gen/psignal.c +++ lib/libc/gen/psignal.c @@ -61,3 +61,9 @@ psignal(unsigned int sig, const char *s) iov[niov+1].iov_len = 1; (void)writev(STDERR_FILENO, iov, niov+2); } + +void +psiginfo(const siginfo_t *si, const char *s) +{ + psignal(si->si_signo, s); +}