the getrandom man page says:
The behavior when a call to getrandom() that is blocked while reading
from the urandom source is interrupted by a signal handler depends on
the initialization state of the entropy buffer and on the request
size, buflen. If the entropy is not yet initialized, then the call
fails with the EINTR error. If the entropy pool has been initialized
and the request size is large (buflen > 256), the call either
succeeds, returning a partially filled buffer, or fails with the
error EINTR. If the entropy pool has been initialized and the
request size is small (buflen <= 256), then getrandom() will not fail
with EINTR. Instead, it will return all of the bytes that have been
this part clearly says that in this circumstance it will return EINTR. however, it also says:
EINTR The call was interrupted by a signal handler; see the
description of how interrupted read(2) calls on "slow" devices
are handled with and without the SA_RESTART flag in the
signal(7) man page.
and in signal(7) it says:
If a blocked call to one of the following interfaces is interrupted
by a signal handler, then the call is automatically restarted after
the signal handler returns if the SA_RESTART flag was used; otherwise
the call fails with the error EINTR:
this strongly implies that if all signal handlers have SA_RESTART, then getrandom will never return EINTR.
so which is it? (I guess I could test it...)
but either way, the first part should be amended to either say "unless SA_RESTART was specified for the signal handler" or it should say "even if SA_RESTART ..."
Created attachment 275963 [details]
I tested this program and found that getrandom respects SA_RESTART if the pool is not initialized.