1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Epoll and SIGALRM (setitimer) conflict

Discussion in 'C' started by Jamesbch, Aug 28, 2010.

  1. Jamesbch

    Jamesbch New Member

    Aug 28, 2010
    Likes Received:
    Trophy Points:
    Hello there,

    I'm developing a server which use epoll to manage the incoming connections. I'm working at the moment on timers and I'm using the setitimer and sigaction interface of Linux. It's working well but I've found out that epoll and setitimer conflict each other: I guess they share the same signal SIGALRM because of this :
             int nfds, fd;
            struct epoll_event events[MAX_EPOLL_EVENTS_PER_RUN];
            while (1) {
                    nfds = epoll_wait(_epoll_clients, events,
                    if (nfds < 0) {
                            // Is triggered when a timer has timeout
    In the normal situations I would simply exit when epoll_wait returns a negative value but I don't want my program to quit when I'm using a timer. I tried to put a bool when a timer is scheduled and check it here. Unfortunately It didn't work when only 1 timer is scheduled because the epoll event comes AFTER my timer callback has finished its work (like resetting the bool). :icon_frown:

    Can you give me some advices or solution, please ? Many thanks in advance.

Share This Page