[Python-checkins] cpython (3.5): py_getrandom(): getrandom() *can* return EINTR

victor.stinner python-checkins at python.org
Thu Jul 30 10:16:16 CEST 2015


https://hg.python.org/cpython/rev/25403a40feb2
changeset:   97140:25403a40feb2
branch:      3.5
parent:      97137:8777e59a99bd
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Thu Jul 30 10:13:52 2015 +0200
summary:
  py_getrandom(): getrandom() *can* return EINTR

See the latest version of getrandom() manual page:
http://man7.org/linux/man-pages/man2/getrandom.2.html#NOTES

    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 with the
    EINTR error.  If the entropy pool has been initialized and the request size
    is large (buflen > 256), the call either succeeds, returning a partially
    filled buffer, or fails with the error EINTR.  If the entropy pool has been
    initialized and the request size is small (buflen <= 256), then getrandom()
    will not fail with EINTR.  Instead, it will return all of the bytes that
    have been requested.

Note: py_getrandom() calls getrandom() with flags=0.

files:
  Python/random.c |  1 -
  1 files changed, 0 insertions(+), 1 deletions(-)


diff --git a/Python/random.c b/Python/random.c
--- a/Python/random.c
+++ b/Python/random.c
@@ -142,7 +142,6 @@
             }
 
             if (errno == EINTR) {
-                /* Note: EINTR should not occur with flags=0 */
                 if (PyErr_CheckSignals()) {
                     if (!raise)
                         Py_FatalError("getrandom() interrupted by a signal");

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list