diff -ru python3.5-3.5.1-orig/configure.ac python3.5-3.5.1/configure.ac --- python3.5-3.5.1-orig/configure.ac 2015-12-07 01:39:11.000000000 +0000 +++ python3.5-3.5.1/configure.ac 2016-05-13 09:00:55.356227833 +0100 @@ -1799,7 +1799,7 @@ sys/stat.h sys/syscall.h sys/sys_domain.h sys/termio.h sys/time.h \ sys/times.h sys/types.h sys/uio.h sys/un.h sys/utsname.h sys/wait.h pty.h \ libutil.h sys/resource.h netpacket/packet.h sysexits.h bluetooth.h \ -bluetooth/bluetooth.h linux/tipc.h spawn.h util.h alloca.h endian.h \ +bluetooth/bluetooth.h linux/tipc.h linux/random.h spawn.h util.h alloca.h endian.h \ sys/endian.h) AC_HEADER_DIRENT AC_HEADER_MAJOR diff -ru python3.5-3.5.1-orig/pyconfig.h.in python3.5-3.5.1/pyconfig.h.in --- python3.5-3.5.1-orig/pyconfig.h.in 2015-12-07 01:39:11.000000000 +0000 +++ python3.5-3.5.1/pyconfig.h.in 2016-05-13 09:00:33.689556635 +0100 @@ -546,6 +546,9 @@ /* Define to 1 if you have the header file. */ #undef HAVE_LINUX_TIPC_H +/* Define to 1 if you have the header file. */ +#undef HAVE_LINUX_RANDOM_H + /* Define to 1 if you have the `lockf' function. */ #undef HAVE_LOCKF diff -ru python3.5-3.5.1-orig/Python/random.c python3.5-3.5.1/Python/random.c --- python3.5-3.5.1-orig/Python/random.c 2015-12-07 01:39:11.000000000 +0000 +++ python3.5-3.5.1/Python/random.c 2016-05-13 09:03:53.481323791 +0100 @@ -6,6 +6,9 @@ # ifdef HAVE_SYS_STAT_H # include # endif +# ifdef HAVE_LINUX_RANDOM_H +# include +# endif # ifdef HAVE_GETRANDOM # include # elif defined(HAVE_GETRANDOM_SYSCALL) @@ -124,7 +127,7 @@ static int getrandom_works = 1; /* Use non-blocking /dev/urandom device. On Linux at boot, the getrandom() * syscall blocks until /dev/urandom is initialized with enough entropy. */ - const int flags = 0; + const int flags = GRND_NONBLOCK; int n; if (!getrandom_works) @@ -161,6 +164,10 @@ getrandom_works = 0; return 0; } + if (errno == EAGAIN) { + /* getrandom would block - fail but allow for retry later */ + return 0; + } if (errno == EINTR) { if (PyErr_CheckSignals()) {