~ chicken-core (chicken-5) 9aa95d87db87ec9e4b2b936ddccd7c9dc7dc326f
commit 9aa95d87db87ec9e4b2b936ddccd7c9dc7dc326f Author: felix <felix@call-with-current-continuation.org> AuthorDate: Sun Nov 5 11:45:11 2017 +0100 Commit: felix <felix@call-with-current-continuation.org> CommitDate: Sun Nov 5 11:45:11 2017 +0100 latch onto using /dev/urandom if syscall fails once diff --git a/runtime.c b/runtime.c index 93733761..7b7c3539 100644 --- a/runtime.c +++ b/runtime.c @@ -12582,12 +12582,19 @@ C_word C_random_bytes(C_word buf, C_word size) #ifdef __OpenBSD__ arc4random_buf(C_data_pointer(buf), count); #elif defined(SYS_getrandom) && defined(__NR_getrandom) + static int use_urandom = 0; + + if(use_urandom) return random_urandom(buf, count); + while(count > 0) { /* GRND_NONBLOCK = 0x0001 */ r = syscall(SYS_getrandom, C_data_pointer(buf) + off, count, 1); if(r == -1) { - if(errno == ENOSYS) return random_urandom(buf, count); + if(errno == ENOSYS) { + use_urandom = 1; + return random_urandom(buf, count); + } else if(errno != EINTR) return C_SCHEME_FALSE; else r = 0; }Trap