text: GETRANDOM(2) Linux Programmer's Manual GETRANDOM(2)
  getrandom - obtain a series of random bytes
  #include <linux/random.h> int getrandom(void *buf, size_t buflen, unsigned int flags);
  The getrandom() system call fills the buffer pointed to by buf with up to buflen random bytes. These bytes can be used to seed user- space random number generators or for cryptographic purposes. getrandom() relies on entropy gathered from device drivers and other sources of environmental noise. Unnecessarily reading large quantities of data will have a negative impact on other users of the /dev/random and /dev/urandom devices. Therefore, getrandom() should not be used for Monte Carlo simulations or other programs/algorithms which are doing probabilistic sampling. By default, getrandom() draws entropy from the /dev/urandom pool. This behavior can be changed via the flags argument. If the /dev/urandom pool pool has not yet been initialized, then the call blocks, unless GRND_NONBLOCK is specified in flags. The flags argument is a bit mask that can contain zero or more of the following values ORed together: GRND_RANDOM If this bit is set, then random bytes are drawn from the /dev/random pool instead of the /dev/urandom pool. The /dev/random pool is limited based on the entropy that can be obtained from environmental noise. If the number of available bytes in /dev/random is less than requested in buflen, the call returns just the available random bytes. If no random bytes are available, the behavior depends on the presence of GRND_NONBLOCK in the flags argument. GRND_NONBLOCK By default, when reading from /dev/random, getrandom() blocks if no random bytes are available, and when reading from /dev/urandom, it blocks if the entropy pool has not yet been initialized. If the GRND_NONBLOCK flag is set, then getrandom() does not block in these cases, but instead immediately returns -1 with errno set to EAGAIN.
  On. On error, -1 is returned, and errno is set appropriately..
  getrandom() was introduced in version 3.17 of the Linux kernel.
  This system call is Linux-specific.
  Maximum number of bytes returned As of Linux 3.19 the following limits apply: * When reading from /dev/urandom, a maximum of 33554431 bytes is returned by a single call to getrandom() on a system where int has a size of 32 bits. * When reading from /dev/random, a maximum of 512 bytes is returned. Initialization of the entropy pool). The behavior when a call to getrandom() that is blocked while reading from /dev/urandom is interrupted by a signal handler depends on the initialization state of the entropy buffer and on the request size, buflen. If the entropy is not yet initialized, then the call will fail /dev/random, blocking requests of any size can be interrupted by a signal (the call fails with the error EINTR). Calling getrandom() to read /dev/urandom for small values (<= 256) of buflen is the preferred mode of usage. The special treatment of small values of buflen was designed for compatibility with OpenBSD's getentropy() system call.! Choice of random device; }
  As of Linux 3.19, the following bug exists: * Depending on CPU load, getrandom() does not react to interrupts before reading all bytes requested.
  random(4), urandom(4), signal(7)
  This page is part of release 4.08 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at. Linux 2016-10-08 GETRANDOM(2)