diff --git a/submodules/Postbox/Sources/TimeBasedCleanup.swift b/submodules/Postbox/Sources/TimeBasedCleanup.swift index 1c1a0be7eb..d0b9fddc61 100644 --- a/submodules/Postbox/Sources/TimeBasedCleanup.swift +++ b/submodules/Postbox/Sources/TimeBasedCleanup.swift @@ -19,8 +19,9 @@ public func printOpenFiles() { var flags: Int32 = 0 var fd: Int32 = 0 var buf = Data(count: Int(MAXPATHLEN) + 1) + let maxFd = min(1024, FD_SETSIZE) - while fd < FD_SETSIZE { + while fd < maxFd { errno = 0; flags = fcntl(fd, F_GETFD, 0); if flags == -1 && errno != 0 {