make read fd non-blocking and check for event type when polling

Fixes some of the issues on buildbot. Using a non-blocking fd with edge triggered flag is already suggested in epoll man page (http://linux.die.net/man/4/epoll), apparently I've forgot about that before.