hi
    I thought, if I didn't call the ev_loop_fork in the child, then the
watcher in child wouldn't be triggered.
    This is my code, I build the ev_loop with EVBACKEND_EPOLL and
EVFLAG_NOENV flags, so there is no EVFLAG_FORKCHECK flag, then I comment
the ev_loop_fork call in the child. if everything goes well, I thought the
child will not trigger the timeout callback function. but actually, the
output is something like this:
4980 fork 4981
time out at 4980
time out at 4981
     it means that the watchers also has been triggered in the child.




#include<ev.h>
#include<stdio.h>
#include<unistd.h>

void timeout_cb(EV_P_ ev_timer *w,int revents)
{
    printf("time out at %d\n", getpid());
    ev_break(EV_A_ EVBREAK_ONE);
}

int main()
{
    int ret;
    ev_timer timeout_watcher;

    struct ev_loop *loop = ev_default_loop(EVBACKEND_EPOLL | EVFLAG_NOENV);

    ev_timer_init(&timeout_watcher,timeout_cb,5.5,0.);
    ev_timer_start(loop,&timeout_watcher);
    ret = fork();
    if(ret>0) printf("%d fork %d\n",getpid(),ret);
    else if(ret==0)
    {
        //ev_loop_fork(EV_DEFAULT);
    }
    else return -1;
    ev_run(loop,0);
    return 0;
}
_______________________________________________
libev mailing list
[email protected]
http://lists.schmorp.de/mailman/listinfo/libev

Reply via email to