Change 23898 by [EMAIL PROTECTED] on 2005/01/29 16:14:20

        [perl #33928] chomp() fails after alarm(), `sleep`
        
        PP_backtick's temp altering of PL_rs didn't restore after
        an exception

Affected files ...

... //depot/perl/pp_sys.c#379 edit
... //depot/perl/t/op/alarm.t#7 edit

Differences ...

==== //depot/perl/pp_sys.c#379 (text) ====
Index: perl/pp_sys.c
--- perl/pp_sys.c#378~23842~    Fri Jan 21 02:57:48 2005
+++ perl/pp_sys.c       Sat Jan 29 08:14:20 2005
@@ -345,13 +345,14 @@
                ;
        }
        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);
        }

==== //depot/perl/t/op/alarm.t#7 (text) ====
Index: perl/t/op/alarm.t
--- perl/t/op/alarm.t#6~16619~  Thu May 16 05:16:25 2002
+++ perl/t/op/alarm.t   Sat Jan 29 08:14:20 2005
@@ -13,7 +13,7 @@
     }
 }
 
-plan tests => 4;
+plan tests => 5;
 my $Perl = which_perl();
 
 my $start_time = time;
@@ -48,4 +48,12 @@
     local $TODO = "Why does system() block alarm() on $^O?"
                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`');
 }
End of Patch.

Reply via email to