Fix pioctl input and output handling