my $Is_VMS = $^O eq 'VMS';
my $Is_MacOS = $^O eq 'MacOS';
my $Is_Win32 = $^O eq 'MSWin32';
-my $Is_Cygwin = $^O eq 'cygwin';
# When in doubt, skip.
skip_all("MacOS") if $Is_MacOS;
skip_all("VMS") if $Is_VMS;
-skip_all("cygwin") if $Is_Cygwin;
skip_all("Win32") if $Is_Win32;
sub make_tmp_file {
my $Perl = which_perl();
my $quote = $Is_VMS || $Is_Win32 ? '"' : "'";
-my $tmperr = 'cloexece.tmp';
-my $tmpfile1 = 'cloexec1.tmp';
-my $tmpfile2 = 'cloexec2.tmp';
+my $tmperr = tempfile();
+my $tmpfile1 = tempfile();
+my $tmpfile2 = tempfile();
my $tmpfile1_contents = "tmpfile1 line 1\ntmpfile1 line 2\n";
my $tmpfile2_contents = "tmpfile2 line 1\ntmpfile2 line 2\n";
make_tmp_file($tmpfile1, $tmpfile1_contents);
test_inherited($parentfd1);
close FHPARENT1 or die "close '$tmpfile1': $!";
-# ... and test that you cannot inherit fd = $^F+1.
+# ... and test that you cannot inherit fd = $^F+n.
open FHPARENT1, "<$tmpfile1" or die "open '$tmpfile1': $!";
open FHPARENT2, "<$tmpfile2" or die "open '$tmpfile2': $!";
$parentfd2 = fileno FHPARENT2;
close FHPARENT1 or die "close '$tmpfile1': $!";
# ... and now you can inherit after incrementing.
-++$^F;
+$^F = $parentfd2;
open FHPARENT2, "<$tmpfile2" or die "open '$tmpfile2': $!";
open FHPARENT1, "<$tmpfile1" or die "open '$tmpfile1': $!";
$parentfd1 = fileno FHPARENT1;
test_inherited($parentfd1);
close FHPARENT1 or die "close '$tmpfile1': $!";
close FHPARENT2 or die "close '$tmpfile2': $!";
-
-END {
- defined $tmperr and unlink($tmperr);
- defined $tmpfile1 and unlink($tmpfile1);
- defined $tmpfile2 and unlink($tmpfile2);
-}