handle errors in ioctl