github.com/GuanceCloud/cliutils@v1.1.21/system/system.go (about)

     1  // Unless explicitly stated otherwise all files in this repository are licensed
     2  // under the MIT License.
     3  // This product includes software developed at Guance Cloud (https://www.guance.com/).
     4  // Copyright 2021-present Guance, Inc.
     5  
     6  // Package system used to wrap basic system related settings.
     7  package system
     8  
     9  import (
    10  	"syscall"
    11  )
    12  
    13  func SetSysLimit(x int, n uint64) error {
    14  	var lmt syscall.Rlimit
    15  
    16  	if err := syscall.Getrlimit(x, &lmt); err != nil {
    17  		return err
    18  	}
    19  
    20  	lmt.Max = n
    21  	lmt.Cur = n
    22  
    23  	return syscall.Setrlimit(x, &lmt)
    24  }