rulimit.go 499 B

12345678910111213141516171819
  1. // Copyright 2021 The Sqlite 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. //go:build linux || darwin || netbsd || openbsd
  5. // +build linux darwin netbsd openbsd
  6. package sqlite // import "modernc.org/sqlite"
  7. import (
  8. "golang.org/x/sys/unix"
  9. )
  10. func setMaxOpenFiles(n int64) error {
  11. var rLimit unix.Rlimit
  12. rLimit.Max = uint64(n)
  13. rLimit.Cur = uint64(n)
  14. return unix.Setrlimit(unix.RLIMIT_NOFILE, &rLimit)
  15. }