Files
ARTEX/server/killswitch_prctl_linux.go
T
BaaRai c721a4b8e5 fix(server): keep the linux subreaper call out of the unix build
The v0.7.1 release failed in its darwin binaries job: killswitch_unix.go is
built for every unix target but calls syscall.SYS_PRCTL, which only exists on
Linux. The Linux CI never compiled another GOOS, so the tag passed CI and broke
the release build after the push.

Move the prctl call to killswitch_prctl_linux.go, keep a no-op for the other
unix targets, and add a cross-compile step to the go job so darwin and windows
break in CI instead of in the release.
2026-12-01 04:08:32 +01:00

22 lines
569 B
Go

//go:build linux
package server
import (
"sync"
"syscall"
)
var subreaperOnce sync.Once
// enableLocalKillSubreaper marks the panel process as a Linux child subreaper
// (PR_SET_CHILD_SUBREAPER) so orphaned descendants created via setsid, nohup, or
// double-fork are reparented to this process instead of PID 1 and remain visible
// for deterministic termination on Pause/Stop.
func enableLocalKillSubreaper() {
subreaperOnce.Do(func() {
const prSetChildSubreaper = 36
_, _, _ = syscall.Syscall6(syscall.SYS_PRCTL, prSetChildSubreaper, 1, 0, 0, 0, 0)
})
}