fix polling behaviour and fd_set usage