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,
				MAX_EPOLL_EVENTS_PER_RUN,
				EPOLL_RUN_TIMEOUT);
		
		if (nfds < 0) {
			// Is triggered when a timer has timeout
			perror("epoll");
		}
	}

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.

EINTR
The call was interrupted by a signal handler before any of the requested events occurred or the timeout expired.

source: http://linux.die.net/man/2/epoll_wait

Yes, you are totally right ! I didn't think about errno. Thank you very much.

Edited 6 Years Ago by Jamesbch: n/a

This question has already been answered. Start a new discussion instead.