Derived from a patch proposed by Adhemerval Zanella in:
https://sourceware.org/pipermail/libc-alpha/2021-January/121302.html
* lib/tempname.c (random_bits): Use GRND_NONBLOCK.
2021-01-08 Paul Eggert <eggert@cs.ucla.edu>
+ tempname: don’t block for minutes
+ Derived from a patch proposed by Adhemerval Zanella in:
+ https://sourceware.org/pipermail/libc-alpha/2021-January/121302.html
+ * lib/tempname.c (random_bits): Use GRND_NONBLOCK.
+
tempname: sync with proposed glibc patch
This is from Adhemerval Zanella in:
https://sourceware.org/pipermail/libc-alpha/2021-January/121301.html
random_bits (random_value var)
{
random_value r;
- if (__getrandom (&r, sizeof r, 0) == sizeof r)
+ /* Without GRND_NONBLOCK it can be blocked for minutes on some systems. */
+ if (__getrandom (&r, sizeof r, GRND_NONBLOCK) == sizeof r)
return r;
#if _LIBC || (defined CLOCK_MONOTONIC && HAVE_CLOCK_GETTIME)
- /* Add entropy if getrandom is not supported. */
+ /* Add entropy if getrandom did not work. */
struct __timespec64 tv;
__clock_gettime64 (CLOCK_MONOTONIC, &tv);
var ^= tv.tv_nsec;