<div dir="ltr">Hi Maciej,<br><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Dec 23, 2015 at 3:48 PM, Maciej Fijalkowski <span dir="ltr"><<a href="mailto:fijall@gmail.com" target="_blank">fijall@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">I bet the difference is due to "we see more FDs in pypy". If you close the correct FD in CPython, it would break too I presume? Or is there special code to handle that?</div></blockquote><div><br></div><div>There is special code to handle that in CPython.  It is actually very carefully checking that the FD is still open *and* still pointing to what it used to.  See Python/random.c.<br><br>Just thinking aloud: what could occur here is that the forked process reopens an unrelated file at this descriptor, and then our os.urandom() tries to read from it---and, as a guess, the file happens to be a socket opened in non-blocking mode, and our implementation of os.urandom() gets 0 bytes and keeps trying to get more, which throws it into an infinite loop.<br><br></div><div>It seems it would be a good idea to copy the careful behavior of CPython.  (There used to be another case of file descriptor kept open internally, in rpython/rtyper/lltypesystem/llarena.py for /dev/zero, but this is gone.)<br></div><div><br><br></div><div>A bientôt,<br><br></div><div>Armin.<br></div></div></div></div>