Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Strange Win32::MsgBox behavior with PAR

by ZlR (Chaplain)
on Aug 30, 2006 at 15:15 UTC ( #570406=perlquestion: print w/ replies, xml ) Need Help??
ZlR has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monkz !

Now I have (to me at least) a very strange problem ...

Let's say i do this :

use strict ; use warnings ; use Win32 ; $SIG{ __DIE__ } = sub { Win32::MsgBox ("Error : @_" , 0, $0 ) } ; die "ARRG" ;
When i run this from the command line i get a single warning pop up .

Now if use PAR with :

pp -gui tt.pl -o tt.exe

Then the exe will yield the pop up windows but i will have to click 4 times "OK" to get rid of it !

I'm under XP SP2 ActiveState 5.8. Why, oh, why ??

Update : I thought i should elaborate on why i do this : running an exe with the -gui option is much nicer to the user since it will not launch a "useless" background cmd window. but on the other end it will hide all the error message into nowheresville, unless of course i redirect stderr to a file, but still : it seems better if the error is shown immediatly, hence the MsgBox . Along with this I present the result by calling notepad on a temporary file. This allows me to have a simple "only graphical" interface without using Tk .

Comment on Strange Win32::MsgBox behavior with PAR
Select or Download Code
Replies are listed 'Best First'.
Re: Strange Win32::MsgBox behavior with PAR
by cdarke (Prior) on Aug 30, 2006 at 18:07 UTC
    You had no replies, so I thought I'd try it. If it is any consolation I reproduced your problem easily, I'm using XP SP2 with ActiveState perl 5.8.8 and PAR 0.952. I spotted a comment in the PAR documentation concerning Glade and stack unwinding as a bug - possibly related?
    As an alternative work-around:
    use strict ; use warnings ; use Win32 ; sub die_handler { Win32::MsgBox ("Error : @_" , 0, $0 ) } ; eval {die "ARRG" }; die_handler ("$@") if $@; print "Ended OK\n";
    Seems to work correctly. I suggest you use this method of trapping die's, and report a bug to the PAR guys.
      Hi cdarke,

      Thanks for your solution. Since this means i must eval die and "handle" every time the program dies I simply wrote a

      personal_death  { Win32::MsgBox ("Error :  @_ " ,  0, $0 ) ; exit }

      function . I use it instead of die thru all the code .

      Now this is certainly not as clean as the SIG{__DIE__} option, so i reported a bug .

      update:

      $SIG{ __DIE__ } = sub { Win32::MsgBox ("Error : @_ " , 0, $0 ); exit(1 +); } ;

      ... is the way to do it !

Re: Strange Win32::MsgBox behavior with PAR
by Anonymous Monk on Aug 31, 2006 at 06:26 UTC
    You have to click 4 times because you get 4 pop-ups.

    If you add caller information, you can see

    $SIG{ __DIE__ } = sub { $b=join '|',caller(0);Win32::MsgBox ("Error : + @_ ($b)" , 0, $0 ) } ;
    The PAR team would probably consider this an oversight (bug). This is the code which ultimately executes your program.
    $ENV{PAR_0} = $filename; # for Pod::Usage { do 'main'; CORE::exit($1) if ($@ =~/^_TK_EXIT_\((\d+)\)/); die $@ if $@; exit; }

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://570406]
Approved by socketdave
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (9)
As of 2015-07-30 10:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (271 votes), past polls