Skip to content

Instantly share code, notes, and snippets.

@jasongerard
Created November 15, 2018 03:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasongerard/c5430ed0641b401e8e08abe72dc90169 to your computer and use it in GitHub Desktop.
Save jasongerard/c5430ed0641b401e8e08abe72dc90169 to your computer and use it in GitHub Desktop.
package main
import (
"fmt"
"syscall"
"golang.org/x/sys/unix"
)
func main() {
err := unix.Mlockall(unix.MCL_CURRENT | unix.MCL_FUTURE)
switch err {
case nil:
fmt.Println("Great Success!")
case syscall.ENOMEM:
fmt.Println("ENOMEM: nonzero RLIMIT_MEMLOCK soft resource limit")
case syscall.EPERM:
fmt.Println("EPERM : caller not privileged")
default:
se := err.(syscall.Errno)
fmt.Printf("%v:%s", uintptr(se), err)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment