add error handling for select(2)