Created
November 1, 2018 19:44
-
-
Save williammartin/eb355f7d387791a9c225361e5d19ea40 to your computer and use it in GitHub Desktop.
subreaper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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