From 053e5e69147a3fd3983feccc796db8696c36b116 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Tue, 27 Jan 2015 13:23:59 +0100 Subject: [PATCH] getrandom.2: Enhance discussion of /dev/urandom reads in DESCRIPTION Signed-off-by: Michael Kerrisk --- man2/getrandom.2 | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/man2/getrandom.2 b/man2/getrandom.2 index 5e4ca7121..f66cebe7c 100644 --- a/man2/getrandom.2 +++ b/man2/getrandom.2 @@ -65,7 +65,20 @@ This behavior can be changed via the argument. If the .IR /dev/urandom -pool has been initialized, reading from that pool never blocks. +pool has been initialized, +reads of up to 256 bytes will always return as many bytes as +requested and will not be interrupted by signals. +No such guarantees apply for larger buffer sizes. +For example, if the call is interrupted by a signal handler, +it may return a partially filled buffer, or fail with the error +.BR EINTR . +.\" Tested with buffer sizes > 256 bytes: both partial reads +.\" and EINTR can occur, with the former being more frequent. +.\" +.\" mtk: In the absence of signals, in my testing, even very large reads +.\" return full buffers. I found that reads of up to 33554431 always +.\" returned a filled buffer. Specifying 'buflen' > 33554431 always +.\" returned just 33554431 bytes. (I'm not sure where that number comes from. If the pool has not yet been initialized, then the call blocks, unless .B GRND_RANDOM is specified in