You mutation lover: use Posix.IO.readVec and Pack32Little.subVec instead of Posix.IO.readArr and Pack32Little.subArr. As to the exception to raise, I don't know. For /dev/random, you might hang, but you shouldn't get back a short read. For /dev/urandom, even the hang shouldn't happen. If you get a short result back, something is really insane.