Esempio n. 1
0
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),
	}
}
Esempio n. 2
0
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
}
Esempio n. 3
0
func sysUnRlimit() *C.struct_rlimit {
	return &C.struct_rlimit{
		C.rlim_t(C.RLIM_INFINITY),
		C.rlim_t(C.RLIM_INFINITY),
	}
}
Esempio n. 4
0
func sysMaxFDs() (*C.struct_rlimit, error) {
	return &C.struct_rlimit{
		C.rlim_t(C.OPEN_MAX),
		C.rlim_t(C.OPEN_MAX),
	}, nil
}