func sysUnRlimit() *C.struct_rlimit { // this constant is set to -1. in C, you can coerce this to an // unsigned integer, but in go, you cannot // we have to delay the signed->unsigned cast until runtime to // avoid compile errors inf := C.RLIM_INFINITY return &C.struct_rlimit{ C.rlim_t(inf), C.rlim_t(inf), } }
func sysMaxFDs() (*C.struct_rlimit, error) { nrOpen, err := ioutil.ReadFile("/proc/sys/fs/nr_open") if err != nil { return nil, util.Errorf("Could not read \"/proc/sys/fs/nr_open\": %s", err) } maxFDs, err := strconv.Atoi(strings.TrimSpace(string(nrOpen))) if err != nil { return nil, util.Errorf("Could not convert %q (from \"/proc/sys/fs/nr_open\") into int: %s", nrOpen, err) } return &C.struct_rlimit{ C.rlim_t(maxFDs), C.rlim_t(maxFDs), }, nil }
func sysUnRlimit() *C.struct_rlimit { return &C.struct_rlimit{ C.rlim_t(C.RLIM_INFINITY), C.rlim_t(C.RLIM_INFINITY), } }
func sysMaxFDs() (*C.struct_rlimit, error) { return &C.struct_rlimit{ C.rlim_t(C.OPEN_MAX), C.rlim_t(C.OPEN_MAX), }, nil }