Use select() syscall to avoid busy waiting