develooper Front page | perl.perl5.porters | Postings from January 2011

[perl #81586] Carp::confess looses $! on Windows

From:
Mark Overmeer
Date:
January 3, 2011 14:17
Subject:
[perl #81586] Carp::confess looses $! on Windows
Message ID:
rt-3.6.HEAD-5425-1294043007-979.81586-75-0@perl.org
# New Ticket Created by  Mark Overmeer 
# Please include the string:  [perl #81586]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=81586 >



(no detailed Perl -V information because the bug is on Windows which
I do not run... discovered by cpantesters)

The following script catches the die() used by Carp::confess.  Only
on Windows, the $! get descroyed when confess is used with "\n".

  #!/usr/bin/perl
  use warnings;
  use strict;

  use Carp;

  $SIG{__DIE__} = sub { print "@_: $! (rc=".($!+0).")\n" };

  print "--> without \\n\n";
  eval { $! = 3; confess "oeps" };
  print "\n--> with \\n\n";
  eval { $! = 3; confess "oeps\n" };

Output on all platforms except Windows (afaik) as expected:

  --> without \n
  oeps at /tmp/y line 10
          eval {...} called at /tmp/y line 10
  : No such process (rc=3)

  --> with \n
  oeps
   at /tmp/y line 12
          eval {...} called at /tmp/y line 12
  : No such process (rc=3)

Output when run on Strawberry Perl 5.12.1.0 (x64)   (and other 
versions of Windows)

  --> without \n
  oeps at y line 10                                                            
      eval {...} called at y line 10                                           
  : No such process (rc=3)                                                     
                                                                               
  --> with \n                                                                  
  oeps                                                                         
   at y line 12                                                                
      eval {...} called at y line 12                                           
  :  (rc=0)

-- 
Regards,
               MarkOv

------------------------------------------------------------------------
       Mark Overmeer MSc                                MARKOV Solutions
       Mark@Overmeer.net                          solutions@overmeer.net
http://Mark.Overmeer.net                   http://solutions.overmeer.net




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About