reimplement wait ioctl with index (not ptr)