X-Recipient: archive-cygwin AT delorie DOT com X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL,BAYES_00,SARE_MSGID_LONG40,SPF_PASS X-Spam-Check-By: sourceware.org MIME-Version: 1.0 In-Reply-To: References: Date: Thu, 22 Oct 2009 20:55:57 +0100 Message-ID: <416096c60910221255i550948a1n10301cd417e9f5cd@mail.gmail.com> Subject: Re: Python throws error when closing /dev/urandom From: Andy Koppe To: cygwin AT cygwin DOT com Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner AT cygwin DOT com Mail-Followup-To: cygwin AT cygwin DOT com Delivered-To: mailing list cygwin AT cygwin DOT com 2009/10/22 Topher Cawlfield > I'm not sure if this is the right place to post such problems, but I ran = into > this problem when trying to use the paramiko library with python 2.5.2 in= Cygwin. > > Ultimately the problem is that an IOError is generated when opening > /dev/urandom, reading some bytes from it (doesn't seem to matter how much= ), > and closing the file. =C2=A0If you don't read from the file there is no e= rror upon > closing. > > $ python > Python 2.5.2 (r252:60911, Dec =C2=A02 2008, 09:26:14) > [GCC 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)] on cygwin > Type "help", "copyright", "credits" or "license" for more information. > .>>> f =3D open("/dev/urandom") > .>>> f.close() > > Note: no problem just opening and closing the special file. =C2=A0But: > > .>>> f =3D open("/dev/urandom") > .>>> f.read(8) > '\xf9"\xb7\'E\xf8Q\xa0' > .>>> f.close() > Traceback (most recent call last): > =C2=A0File "", line 1, in > IOError: [Errno 0] Error > .>>> Reproduced the issue with this C test: #include #include int main(void) { FILE *f =3D fopen("/dev/urandom", "r"); if (!f) { puts("fopen failed"); return 1; } char buf[8]; printf("read %i bytes\n", fread(buf, 1, sizeof buf, f)); if (fclose(f)) { puts("fclose failed"); return 1; } return 0; } The fclose fails on Cygwin, but succeeds on Debian. Andy -- Problem reports: http://cygwin.com/problems.html FAQ: http://cygwin.com/faq/ Documentation: http://cygwin.com/docs.html Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple