I'm trying to use libevent for reading data from stdin, and my callback
is being called over and over, even though i'm only sending a couple of
bytes to stdin. 
Here's the jist of it:

Main:
    event_init();
    event_set(&ev, 0 /*stdin*/, EV_READ | EV_PERSIST, read_stdin, NULL);
    event_add(&ev, NULL);
    event_dispatch();


void read_stdin(int fd, short flags, void *data)
{
    int b;
    b = read(fd, buffer, 0);
    fprintf(stderr, "Read %d bytes from %d:", b, fd);
    fprintf(stderr, "'%.*s' ", b, buffer);
    return;
}

Now if i do:

mkfifo fifo
./prog < fifo

and then in another shell:
echo -n "12345" > fifo

i see:
Read 5 bytes from 0:'12345' Read 0 bytes from 0:'' Read 0 bytes from
0:'' Read 0 bytes from 0:'' ...

And the callback keeps firing forever, even tho I'm not sending any more
data. I can't find anything in the docs about having to acknowledge
events or dismiss them once fired or anything - what am i missing?

Thanks,
RJ




_______________________________________________
Libevent-users mailing list
Libevent-users@monkey.org
http://monkeymail.org/mailman/listinfo/libevent-users

Reply via email to