tech-kern archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
maximum limit of files open with O_EXLOCK
per https://github.com/ziglang/zig/issues/9162,
There seems to be a limit somewhere that causes open() to return ENOMEM
when 1000+ files are opened with O_EXLOCK, this is independent of any
"open file" limits.
I eyeballed the vfs syscalls code but couldn't figure out where
ENOMEM is coming from. The problem seems filesystem independent - I
tried with tmpfs and ZFS and got the same result with both.
Here's a simple reproducer:
#include <sys/param.h>
#include <stdio.h>
#include <stdlib.h>
#include <fcntl.h>
#include <unistd.h>
#include <errno.h>
#include <string.h>
int main(int argc, char **argv ){
char path[32];
for (int i = 0; i < 2000; ++i) {
snprintf(path, sizeof(path), "/tmp/XXX%d", i);
int n = open(path, O_CREAT | O_EXLOCK);
if (n == -1) {
printf("bleh %d: %s\n", i, strerror(errno));
return 1;
}
}
return 0;
}
$ ./a.out
bleh 1010: Cannot allocate memory
While it's arguable that what Zig is doing here isn't sensible,
it would be nice to know where the limit is coming from and whether
it's adjustable.
Home |
Main Index |
Thread Index |
Old Index