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.

Recommended Answers

All 2 Replies

Just check errno. It should be set to 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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.