lock_file: better message if too many open files

Recommend using `ulimit -n` to increase maximum
number of open files.
This commit is contained in:
Steve Peters 2023-03-03 18:27:00 -08:00
parent 5cac33c2a9
commit 116fd5928c

View File

@ -42,7 +42,11 @@ class LockFile
def create_lockfile def create_lockfile
return if @lockfile.present? && !@lockfile.closed? return if @lockfile.present? && !@lockfile.closed?
@lockfile = @path.open(File::RDWR | File::CREAT) begin
@lockfile = @path.open(File::RDWR | File::CREAT)
rescue Errno::EMFILE
odie "The maximum number of open files on this system has been reached. Use `ulimit -n` to increase this limit."
end
@lockfile.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC) @lockfile.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
end end
end end