Created
October 23, 2017 04:31
-
-
Save kazuho/474bc4a15f8e2a0bb2d7cb4a921b708a to your computer and use it in GitHub Desktop.
failed after 2556 iterations: at tmp/runprog.pl line 15, <$fh> line 1.
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
use File::Temp qw(tempfile); | |
sub run_prog { | |
my $cmd = shift; | |
my ($tempfh, $tempfn) = tempfile(UNLINK => 1); | |
my $stderr = `$cmd 2>&1 > $tempfn`; | |
my $stdout = do { local $/; <$tempfh> }; | |
# close $tempfh; # これがないと、いずれ too many open files になる | |
return ($stderr, $stdout); | |
} | |
my ($stderr, $stdout); | |
for my $i (1..10000) { | |
($stderr, $stdout) = run_prog("/bin/echo Hi"); | |
die "failed after $i iterations:$!" unless $stdout eq "Hi\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment