Skip to content

Commit

Permalink
lock_file: better message if too many open files
Browse files Browse the repository at this point in the history
Recommend using `ulimit -n` to increase maximum
number of open files.
  • Loading branch information
scpeters committed Mar 7, 2023
1 parent 5cac33c commit 116fd59
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Library/Homebrew/lock_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,11 @@ def with_lock
def create_lockfile
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)
end
end
Expand Down

0 comments on commit 116fd59

Please sign in to comment.