github.com/anycable/anycable-go@v1.5.1/utils/os_limits.go (about)

     1  //go:build !windows
     2  // +build !windows
     3  
     4  package utils
     5  
     6  import (
     7  	"fmt"
     8  	"syscall"
     9  )
    10  
    11  // OpenFileLimit returns a string displaying the current open file limit
    12  // for the process or unknown if it's not possible to detect it
    13  func OpenFileLimit() (limitStr string) {
    14  	var rLimit syscall.Rlimit
    15  
    16  	if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rLimit); err != nil {
    17  		limitStr = "unknown"
    18  	} else {
    19  		limitStr = fmt.Sprintf("%d", rLimit.Cur)
    20  	}
    21  
    22  	return
    23  }