//go:build linux package main import ( "errors" "os" "syscall" ) // Arm the signal after NotifyContext, before creating any resources. Unlike a // shell trap, Linux delivers it even when the CLI parent is killed with SIGKILL. func guardParentDeath() error { parent := os.Getppid() _, _, errno := syscall.RawSyscall6(syscall.SYS_PRCTL, 1, uintptr(syscall.SIGTERM), 0, 0, 0, 0) if errno != 0 { return errno } if os.Getppid() != parent { return errors.New("E2E parent exited during setup") } return nil }