untrusted comment: verify with openbsd-78-base.pub
RWS3/nvFmk4SWUAvXd/VfdDx83OCeCr/YKEtul0lG/UfDtF7n7JOAGlSjxuob/PL+Hp22KcV2R0UI1vTEYEnAXlblJ6hVRNViwM=

OpenBSD 7.8 errata 031, April 17, 2026:

pgrp management through a fork is unsafe.

Apply by doing:
    signify -Vep /etc/signify/openbsd-78-base.pub -x 031_pgrp.patch.sig \
        -m - | (cd /usr/src && patch -p0)

And then rebuild and install a new kernel:
    KK=`sysctl -n kern.osversion | cut -d# -f1`
    cd /usr/src/sys/arch/`machine`/compile/$KK
    make obj
    make config
    make
    make install

Index: sys/kern/kern_fork.c
===================================================================
RCS file: /cvs/src/sys/kern/kern_fork.c,v
diff -u -p -u -r1.278 kern_fork.c
--- sys/kern/kern_fork.c	18 Aug 2025 04:15:35 -0000	1.278
+++ sys/kern/kern_fork.c	14 Apr 2026 05:17:01 -0000
@@ -236,6 +236,7 @@ process_new(struct proc *p, struct proce
 
 	/* post-copy fixups */
 	pr->ps_pptr = parent;
+	pr->ps_pgrp = NULL;
 	pr->ps_ppid = parent->ps_pid;
 
 	WITNESS_SETCHILD(&pr->ps_mtx.mtx_lock_obj,
@@ -457,6 +458,7 @@ fork1(struct proc *curp, int flags, void
 	LIST_INSERT_HEAD(TIDHASH(p->p_tid), p, p_hash);
 	LIST_INSERT_HEAD(PIDHASH(pr->ps_pid), pr, ps_hash);
 	LIST_INSERT_AFTER(curpr, pr, ps_pglist);
+	pr->ps_pgrp = curpr->ps_pgrp;
 	LIST_INSERT_HEAD(&curpr->ps_children, pr, ps_sibling);
 
 	mtx_enter(&pr->ps_mtx);
