Return error code if reading /dev/random fails

The /dev/random random number provider uses may potentially enter an
infinite loop. It calls fread repeatedly until it completes
successfully. This might loop forever if an error occurs. It should
instead exit with an appropriate error code.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>
Restart fread if it was interrupted

The call to fread might be interrupted and has to be restarted. Check
errno and restart the call if it's set to either EAGAIN or EINTR. Return
the internal error code otherwise.

Signed-off-by: Marcus Karlsson <mk@acc.umu.se>