Created
February 25, 2009 01:55
-
-
Save dagolden/69940 to your computer and use it in GitHub Desktop.
perl require bug?
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
# with STDIN closed, $Config{$var} leaves the STDIN fd open | |
$ perl -MConfig -wE 'close STDIN; open my $fh, "</dev/null"; say fileno $fh; close $fh; say $Config{d_fork}; open $fh, "</dev/null"; say fileno $fh; close $fh' | |
0 | |
define | |
3 | |
# with STDIN as normal, $Config{$var} doesn't leak an fd | |
$ perl -MConfig -wE 'open my $fh, "</dev/null"; say fileno $fh; close $fh; say $Config{d_fork}; open $fh, "</dev/null"; say fileno $fh; close $fh' | |
3 | |
define | |
3 | |
# the issue seems to be the 'require' statement when STDIN is closed | |
$ perl -wE 'close STDIN; open my $fh, "</dev/null"; say fileno $fh; close $fh; require "Config_heavy.pl"; open $fh, "</dev/null"; say fileno $fh; close $fh' | |
0 | |
3 | |
# another example of 'require' with STDIN closed | |
$ perl -wE 'close STDIN; open my $fh, "</dev/null"; say fileno $fh; close $fh; require File::Temp; open $fh, "</dev/null"; say fileno $fh; close $fh' | |
0 | |
3 | |
# an example of require with STDIN normal | |
$ perl -wE 'open my $fh, "</dev/null"; say fileno $fh; close $fh; require File::Temp; open $fh, "</dev/null"; say fileno $fh; close $fh' | |
3 | |
3 | |
# an example without require with STDIN as usual | |
$ perl -MConfig -wE 'open my $fh, "</dev/null"; say fileno $fh; close $fh; ; open $fh, "</dev/null"; say fileno $fh; close $fh' | |
3 | |
3 | |
# an example without require with STDIN closed | |
$ perl -MConfig -wE 'close STDIN; open my $fh, "</dev/null"; say fileno $fh; close $fh; ; open $fh, "</dev/null"; say fileno $fh; close $fh' | |
0 | |
0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment