예제 #1
0
파일: main_linux.go 프로젝트: petertseng/p2
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),
	}
}
예제 #2
0
파일: main_linux.go 프로젝트: petertseng/p2
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
}
예제 #3
0
func sysUnRlimit() *C.struct_rlimit {
	return &C.struct_rlimit{
		C.rlim_t(C.RLIM_INFINITY),
		C.rlim_t(C.RLIM_INFINITY),
	}
}
예제 #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
}