From: Nick Ing-Simmons Date: Fri, 25 Jan 2002 21:37:03 +0000 (+0000) Subject: Save $! so that other syscalls don't disturb it before X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b5d2fea7d685aa8937f7ded78f879c6c841bf93a;p=p5sagit%2Fp5-mst-13.2.git Save $! so that other syscalls don't disturb it before we test it. p4raw-id: //depot/perlio@14422 --- diff --git a/ext/Socket/socketpair.t b/ext/Socket/socketpair.t index 639606a..d14ccb4 100644 --- a/ext/Socket/socketpair.t +++ b/ext/Socket/socketpair.t @@ -9,7 +9,7 @@ BEGIN { require Config; import Config; $can_fork = $Config{d_fork} || ($^O eq 'MSWin32' && $Config{useithreads}); - if ($^O eq "hpux" or $Config{'extensions'} !~ /\bSocket\b/ && + if ($^O eq "hpux" or $Config{'extensions'} !~ /\bSocket\b/ && !(($^O eq 'VMS') && $Config{d_socket})) { print "1..0\n"; exit 0; @@ -110,18 +110,25 @@ ok (shutdown(LEFT, SHUT_WR), "shutdown left for writing"); alarm 60; } +my $err = $!; $SIG{PIPE} = 'IGNORE'; { local $SIG{ALRM} = sub { warn "syswrite to left didn't fail within 3 seconds" }; alarm 3; - is (syswrite (LEFT, "void"), undef, "syswrite to shutdown left should fail"); + # Split the system call from the is() - is() does IO so + # (say) a flush may do a seek which on a pipe may disturb errno + my $ans = syswrite (LEFT, "void"); + $err = $!; + is ($ans, undef, "syswrite to shutdown left should fail"); alarm 60; } { - # This may need skipping on some OSes + # This may need skipping on some OSes - restoring value saved above + # should help + $! = $err; ok (($!{EPIPE} or $!{ESHUTDOWN}), '$! should be EPIPE or ESHUTDOWN') - or printf "\$\!=%d(%s)\n", $!, $!; + or printf "\$\!=%d(%s)\n", $err, $err; } my @gripping = (chr 255, chr 127);