Add select to check timeout

This somehow prevent ioctl from blocking the thread?