From: Deepa Dinamani
Sent: 24 May 2019 18:02
...
Maybe a crude userspace application could do something like this:
sig_handler() { set global abort = 1 }
poll_the_fds() { ret = epoll_pwait() if (ret) return ret if (abort) // but this abort should be ignored if ret was 0. return try_again
}
As an application writer I'd want to see 'abort == 1' even if epoll_pwait() returned that an fd was 'ready'.
So the code above should probably be: wait_again: ret = epoll_pwait(); if (abort) process_abort(); if (ret <= 0) { if (ret == 0) process_timeout(); if (ret == 0 || errno == EINTR) goto wait_again; // Something went horribly wrong in epoll_pwait() return ret; } // process the 'ready' fds
It would be non-unreasonable for the application to have all signals blocked except during the epoll_pwait(). So the application needs the signal handler for SIG_INT (etc) to be called even if one of the fd is always 'ready'.
David
- Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)