-
-
Save lasryaric/6023444 to your computer and use it in GitHub Desktop.
fd.c
file descriptor limit checker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #include <sys/types.h> | |
| #include <sys/stat.h> | |
| #include <fcntl.h> | |
| #include <stdio.h> | |
| int main() | |
| { | |
| int i = 0; | |
| while (i < 66000) { | |
| int fd = open("file.txt", O_RDONLY); | |
| printf("fd = %d\n", fd); | |
| if (fd == -1) { | |
| return 0; | |
| } | |
| i++; | |
| } | |
| return 0; | |
| } |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It may looks useless but it is actually very useful to check the number of authorized file descriptors to open in the current context.
cc fd.c && ./a,out
This will print the maximum number.