Skip to content

Instantly share code, notes, and snippets.

@williammartin
Created November 1, 2018 19:44
Show Gist options
  • Save williammartin/eb355f7d387791a9c225361e5d19ea40 to your computer and use it in GitHub Desktop.
Save williammartin/eb355f7d387791a9c225361e5d19ea40 to your computer and use it in GitHub Desktop.
subreaper
package subreaper
import (
"unsafe"
"golang.org/x/sys/unix"
)
func Set() error {
return unix.Prctl(unix.PR_SET_CHILD_SUBREAPER, uintptr(1), 0, 0, 0)
}
func Unset() error {
return unix.Prctl(unix.PR_SET_CHILD_SUBREAPER, uintptr(0), 0, 0, 0)
}
func IsSubreaper() (bool, error) {
var i uintptr
if err := unix.Prctl(unix.PR_GET_CHILD_SUBREAPER, uintptr(unsafe.Pointer(&i)), 0, 0, 0); err != nil {
return false, err
}
return (int(i) != 0), nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment