From: Dave Mitchell Date: Sat, 29 Jan 2005 16:14:20 +0000 (+0000) Subject: [perl #33928] chomp() fails after alarm(), `sleep` X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=75af1a9c52a124d2be09fece4ba0d7bc6091ed01;p=p5sagit%2Fp5-mst-13.2.git [perl #33928] chomp() fails after alarm(), `sleep` PP_backtick's temp altering of PL_rs didn't restore after an exception p4raw-id: //depot/perl@23898 --- diff --git a/pp_sys.c b/pp_sys.c index 0bb7165..bb843e1 100644 --- 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); } diff --git a/t/op/alarm.t b/t/op/alarm.t index 8fb9296..b77a5ed 100644 --- a/t/op/alarm.t +++ b/t/op/alarm.t @@ -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`'); +}