Last active
August 29, 2015 14:22
-
-
Save martin-ueding/a2b79b500c91e590de5e to your computer and use it in GitHub Desktop.
File descriptor leak test
This file contains 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
// Copyright © 2015 Martin Ueding <dev@martin-ueding.de> | |
// Try to leak as many file descriptors until the program crashes. | |
#include <stdio.h> | |
#include <stdlib.h> | |
int main(int argc, char **argv) { | |
char filename[100]; | |
for (size_t i = 0;; ++i) { | |
sprintf(filename, "/tmp/%ld.txt", i); | |
fopen(filename, "w"); | |
if (i % 1000000 == 0) { | |
printf("%ld\n", i); | |
} | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment