<font style="font-family:courier new,monospace" face="courier new,monospace"><br></font><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">On Fri, Mar 30, 2012 at 3:31 PM, Zsbán Ambrus <<a href="mailto:ambrus@math.bme.hu">ambrus@math.bme.hu</a>> wrote:</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">> On 3/30/12, Fulko Hew <<a href="mailto:fulko.hew@gmail.com">fulko.hew@gmail.com</a>> wrote:</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">> > I tried that (I thought correctly, as per below) and I get an error rather</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">> > than my callback being called.</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">> ></span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">> > Not a GLOB reference at /usr/lib/perl5/site_perl/5.8.8/AnyEvent/Util.pm</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">> > line 592.</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">></span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">> I cannot reproduce your error.  Look, this works fine for me.</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">I've managed to narrow down the problem and create a simple test case shown below.</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">It provides 4 different scenarios (some commented out); but let me explain how I<br>got to this point in my application/module development...<br><br>a) In my module, I needed to capture application failures so that an automated<br>

   clean-up/notification routine could be invoked.  Hence the need/desire to<br>   capture __WARN__ and __DIE__.<br><br>b) When I started my development I used the traditional technique of Perl $SIG{}<br>   coding... which worked!.<br>

<br>c) Then I needed to use the AnyEvent::Util::run_cmd() facility to avoid<br>   (my) networking timeouts, but that initiated the GLOB error.<br><br>It wasn't until now that I've determined the correlation.<br><br>

As implied in the test scenarios below, there doesn't seem to be a consistent<br>way to handle the different signals and get the appropriate response.<br>...It seems that I need to use 'traditional' (#3) for __WARN__,<br>

but now I'm no longer allowed to catch the __DIE__ (now that I need<br>to use run_cmd) unless the GLOB error/issue is resolved).<br><br>[Note: Looking into the underlying Async</span><span style="font-family:courier new,monospace" class="sh_symbol">::</span><span style="font-family:courier new,monospace">Interrupt module, I suspect<br>

       it doesn't currently handle the __xxx__ signals of Perl, only<br>       the OS's signals.]<br><br>------------- test code follows </span><span style="font-family:courier new,monospace">-------------</span><br>

<span style="font-family:courier new,monospace"><br>#!/usr/bin/perl</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">use strict;</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">use warnings;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">use Coro;</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">use AnyEvent;</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">use AnyEvent::Util;</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">use Carp;</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">sub clucker { print "clucker called\n"; Carp::cluck(@_); exit 0; }</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">sub obtainer {</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    my $ps_cv = run_cmd "", ">" => sub {};  # do something</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">    $ps_cv->recv;                           # and wait for it</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    #print "bug!\n" if (undef == 5);        # uncomment to cause a __WARN__</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">    #die;                                   # uncomment to cause a __DIE__</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">}</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">                                                                        #     GLOB      signal</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">                                                                        #    problem?  detected?</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">    $SIG{__DIE__} = \&clucker;                                          # 1/   YES        yes</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">#   my $w=  AnyEvent->signal(signal => "__DIE__", cb => \&clucker);     # 2/   no         NO</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">    $SIG{__WARN__} = \&clucker;                                         # 3/   no         yes</span><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">#   my $d = AnyEvent->signal(signal => "__WARN__", cb => \&clucker);    # 4/   no         NO</span><br style="font-family:courier new,monospace"><br style="font-family:courier new,monospace">

<span style="font-family:courier new,monospace">my $obtainer = AnyEvent->timer(after => 1, cb => \&obtainer);</span><br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace">AnyEvent->condvar->wait;</span><br style="font-family:courier new,monospace">

<br style="font-family:courier new,monospace"><span style="font-family:courier new,monospace"></span>