untrusted comment: verify with openbsd-77-base.pub
RWSbCCUoGpcxVVOjwt89u+t3Z5SJEbGP+Seu99Ps46VULwK0sqA0Lv4hhqvF8PW9JpwrhOALHquNzV8wyltBuZ3bPEUxvrYe0g4=

OpenBSD 7.7 errata 037, April 17, 2026:

pgrp management through a fork is unsafe.

Apply by doing:
    signify -Vep /etc/signify/openbsd-77-base.pub -x 037_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.269 kern_fork.c
--- sys/kern/kern_fork.c	10 Mar 2025 09:28:56 -0000	1.269
+++ sys/kern/kern_fork.c	14 Apr 2026 05:16:13 -0000
@@ -235,6 +235,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;
 
 	/* bump references to the text vnode (for sysctl) */
@@ -455,6 +456,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);
