reproducible GLOB problem, Was: 'how to convert shell captures into anyevent style?'

Fulko Hew fulko.hew at
Wed Apr 4 16:44:31 CEST 2012

On Fri, Mar 30, 2012 at 3:31 PM, Zsbán Ambrus <ambrus at> wrote:
> On 3/30/12, Fulko Hew <fulko.hew at> wrote:
> > I tried that (I thought correctly, as per below) and I get an error
> > than my callback being called.
> >
> > Not a GLOB reference at /usr/lib/perl5/site_perl/5.8.8/AnyEvent/
> > line 592.
> I cannot reproduce your error.  Look, this works fine for me.

I've managed to narrow down the problem and create a simple test case shown
It provides 4 different scenarios (some commented out); but let me explain
how I
got to this point in my application/module development...

a) In my module, I needed to capture application failures so that an
   clean-up/notification routine could be invoked.  Hence the need/desire to
   capture __WARN__ and __DIE__.

b) When I started my development I used the traditional technique of Perl
   coding... which worked!.

c) Then I needed to use the AnyEvent::Util::run_cmd() facility to avoid
   (my) networking timeouts, but that initiated the GLOB error.

It wasn't until now that I've determined the correlation.

As implied in the test scenarios below, there doesn't seem to be a
way to handle the different signals and get the appropriate response.
...It seems that I need to use 'traditional' (#3) for __WARN__,
but now I'm no longer allowed to catch the __DIE__ (now that I need
to use run_cmd) unless the GLOB error/issue is resolved).

[Note: Looking into the underlying Async::Interrupt module, I suspect
       it doesn't currently handle the __xxx__ signals of Perl, only
       the OS's signals.]

------------- test code follows -------------


use strict;
use warnings;
use Coro;
use AnyEvent;
use AnyEvent::Util;
use Carp;

sub clucker { print "clucker called\n"; Carp::cluck(@_); exit 0; }

sub obtainer {
    my $ps_cv = run_cmd "", ">" => sub {};  # do something
    $ps_cv->recv;                           # and wait for it
    #print "bug!\n" if (undef == 5);        # uncomment to cause a __WARN__
    #die;                                   # uncomment to cause a __DIE__

#     GLOB      signal

#    problem?  detected?
    $SIG{__DIE__} = \&clucker;                                          #
1/   YES        yes
#   my $w=  AnyEvent->signal(signal => "__DIE__", cb => \&clucker);     #
2/   no         NO

    $SIG{__WARN__} = \&clucker;                                         #
3/   no         yes
#   my $d = AnyEvent->signal(signal => "__WARN__", cb => \&clucker);    #
4/   no         NO

my $obtainer = AnyEvent->timer(after => 1, cb => \&obtainer);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the anyevent mailing list