Use ‘select’ to wait for IO