rlimit_unix.go 440 B

1234567891011121314151617
  1. // Copyright 2015 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // +build darwin dragonfly freebsd linux netbsd openbsd solaris
  5. package nettest
  6. import "syscall"
  7. func maxOpenFiles() int {
  8. var rlim syscall.Rlimit
  9. if err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &rlim); err != nil {
  10. return defaultMaxOpenFiles
  11. }
  12. return int(rlim.Cur)
  13. }