Problem with AnyEvent::Handle and on_eof

Pedro Melo melo at
Sat Mar 7 19:25:22 CET 2009


I'm trying to understand how on_eof works in AnyEvent::Handle. I  
copied the example in the synopsis and added a couple or print  
statements. The code I'm using to test this is at the end of the  

On both Linux (CentOS 4.6 Final) and Mac OS X 10.5.6, I get a strange  
behaviour. If I do this:

touch aa
./ < a

the script never ends. I assumed that the on_eof would be triggered  
and the $cv->send executed, but it never is.

What am I missing? The MODEL I'm using is AnyEvent::Impl::EV.

Thanks in advance,

---- 8< ----
use AnyEvent;
use AnyEvent::Handle;

my $cv = AnyEvent->condvar;
print "Using $AnyEvent::MODEL\n";

my $handle =
    AnyEvent::Handle->new (
       fh => \*STDIN,
       on_eof => sub {
          print "!! EOF\n";

# send some request line
$handle->push_write ("getinfo\015\012");

# read the response line
$handle->push_read (line => sub {
    my ($handle, $line) = @_;
    warn "read line <$line>\n";

---- 8< ----

Pedro Melo
XMPP ID: melo at

More information about the libev mailing list