eio
eio copied to clipboard
Check EINTR is handled correctly
System calls need to be retried if they return EINTR (unless this was due to them being cancelled; you don't always get ECANCELED
in that case).
There is some handling already, e.g. here's eio_linux handling EINTR for rw ops:
https://github.com/ocaml-multicore/eio/blob/85841dc0b779a920bc4b1daca9172456e33988ee/lib_eio_linux/eio_linux.ml#L519-L527
Check if we need this in more places, and also check the eio_luv backend.
@hannesm notes in https://github.com/mirage/mirage-crypto/pull/155#issuecomment-1106412128 that getrandom
needs this too.
We could also just enforce SA_RESTART
.
Not sure how you feel about eio calling sigaction
though.
Reading signal(7), it seems hard to avoid EINTR in all cases. In particular, it seems that SIGCONT
can generate EINTR.
It's also a bit unclear to me what happens with signals and io_uring operations. I would expect that the io_uring_enter
call would return EINTR rather than the individual operations, so maybe the retry logic above isn't even needed. That code has been there since the very first commit by @avsm; I don't know if it was needed for something.
As far as I know this is working correctly everywhere, so I'll close this. We can reopen if we find any remaining places we missed.