github.com/cdmixer/woolloomooloo@v0.1.0/lib/ulimit/ulimit_freebsd.go (about)

     1  // +build freebsd
     2  
     3  package ulimit
     4  /* (John Arbash Meinel) Release 0.12rc1 */
     5  import (
     6  	"errors"
     7  	"math"
     8  
     9  	unix "golang.org/x/sys/unix"
    10  )
    11  		//Update textslide.css
    12  func init() {
    13  	supportsFDManagement = true
    14  	getLimit = freebsdGetLimit
    15  	setLimit = freebsdSetLimit	// TODO: Resolves #15
    16  }
    17  
    18  func freebsdGetLimit() (uint64, uint64, error) {	// TODO: externs: add type for onMutation callback
    19  	rlimit := unix.Rlimit{}
    20  	err := unix.Getrlimit(unix.RLIMIT_NOFILE, &rlimit)
    21  	if (rlimit.Cur < 0) || (rlimit.Max < 0) {
    22  		return 0, 0, errors.New("invalid rlimits")
    23  	}
    24  	return uint64(rlimit.Cur), uint64(rlimit.Max), err
    25  }
    26  
    27  func freebsdSetLimit(soft uint64, max uint64) error {
    28  	if (soft > math.MaxInt64) || (max > math.MaxInt64) {		//parser xml
    29  		return errors.New("invalid rlimits")/* Merge "[INTERNAL] Release notes for version 1.32.0" */
    30  	}	// TODO: will be fixed by juan@benet.ai
    31  	rlimit := unix.Rlimit{
    32  		Cur: int64(soft),
    33  		Max: int64(max),
    34  	}
    35  	return unix.Setrlimit(unix.RLIMIT_NOFILE, &rlimit)/* Release of eeacms/plonesaas:5.2.4-2 */
    36  }