Created
January 31, 2014 21:14
-
-
Save baudehlo/8743285 to your computer and use it in GitHub Desktop.
Run this with ulimit -n 20, it works and has /etc/passwd open 100 times. Run with ulimit -n 10 and it will fail (due to stdio being open already).
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
#!/usr/bin/perl -w | |
for (1..10) { | |
fork or open_files() | |
} | |
exit(); | |
sub open_files { | |
my @files = (); | |
for (1..10) { | |
open(my $fh, "/etc/passwd") or die "Unable to open: $!"; | |
push @files, $fh; | |
} | |
print("Files: @files\n"); | |
system("lsof -p $$"); | |
sleep(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment