This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Integrate:
authorNicholas Clark <nick@ccl4.org>
Sat, 5 Feb 2005 14:32:42 +0000 (14:32 +0000)
committerNicholas Clark <nick@ccl4.org>
Sat, 5 Feb 2005 14:32:42 +0000 (14:32 +0000)
[ 23898]
[perl #33928] chomp() fails after alarm(), `sleep`

PP_backtick's temp altering of PL_rs didn't restore after
an exception

[ 23905]
Fix test suite hang on Win32 caused by change #23898

("perl -e sleep 3" does an indefinite sleep!)
p4raw-link: @23905 on //depot/perl: 28849697770a958b354afa3e546276a6f15f1d28
p4raw-link: @23898 on //depot/perl: 75af1a9c52a124d2be09fece4ba0d7bc6091ed01

p4raw-id: //depot/maint-5.8/perl@23934
p4raw-integrated: from //depot/perl@23933 'copy in' t/op/alarm.t
(@23898..) 'merge in' pp_sys.c (@23842..)

pp_sys.c
t/op/alarm.t

index 1f1cf1d..c53be3e 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -345,13 +345,14 @@ PP(pp_backtick)
                ;
        }
        else if (gimme == G_SCALAR) {
-           SV *oldrs = PL_rs;
+           ENTER;
+           SAVESPTR(PL_rs);
            PL_rs = &PL_sv_undef;
            sv_setpv(TARG, ""); /* note that this preserves previous buffer */
            while (sv_gets(TARG, fp, SvCUR(TARG)) != Nullch)
                /*SUPPRESS 530*/
                ;
-           PL_rs = oldrs;
+           LEAVE;
            XPUSHs(TARG);
            SvTAINTED_on(TARG);
        }
index 8fb9296..8be24db 100644 (file)
@@ -13,7 +13,7 @@ BEGIN {
     }
 }
 
-plan tests => 4;
+plan tests => 5;
 my $Perl = which_perl();
 
 my $start_time = time;
@@ -49,3 +49,11 @@ is( $@, "ALARM!\n",             'alarm w/$SIG{ALRM} vs system()' );
                if $^O eq 'VMS' || $^O eq'MacOS' || $^O eq 'dos';
     ok( abs($diff - 3) <= 1,   "   right time (waited $diff secs for 3-sec alarm)" );
 }
+
+
+{
+    local $SIG{"ALRM"} = sub { die };
+    eval { alarm(1); my $x = qx($Perl -e "sleep 3") };
+    chomp (my $foo = "foo\n");
+    ok($foo eq "foo", '[perl #33928] chomp() fails after alarm(), `sleep`');
+}