delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2009/10/22/16:11:57

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: <416096c60910221255i550948a1n10301cd417e9f5cd@mail.gmail.com>
References: <loom DOT 20091022T210419-725 AT post DOT gmane DOT org> <416096c60910221255i550948a1n10301cd417e9f5cd AT mail DOT gmail DOT com>
Date: Thu, 22 Oct 2009 21:11:14 +0100
Message-ID: <416096c60910221311n5f3d5f4m673dacebdc89833e@mail.gmail.com>
Subject: Re: Python throws error when closing /dev/urandom
From: Andy Koppe <andy DOT koppe AT gmail DOT com>
To: cygwin AT cygwin DOT com
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
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 i=
n 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 muc=
h),
>> and closing the file. =C2=A0If you don't read from the file there is no =
error 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 "<stdin>", line 1, in <module>
>> IOError: [Errno 0] Error
>> .>>>
>
> Reproduced the issue with this C test:
>
> #include <stdlib.h>
> #include <stdio.h>
>
> int main(void) {
> =C2=A0FILE *f =3D fopen("/dev/urandom", "r");
> =C2=A0if (!f) {
> =C2=A0 =C2=A0puts("fopen failed");
> =C2=A0 =C2=A0return 1;
> =C2=A0}
> =C2=A0char buf[8];
> =C2=A0printf("read %i bytes\n", fread(buf, 1, sizeof buf, f));
> =C2=A0if (fclose(f)) {
> =C2=A0 =C2=A0puts("fclose failed");
> =C2=A0 =C2=A0return 1;
> =C2=A0}
> =C2=A0return 0;
> }
>
> The fclose fails on Cygwin, but succeeds on Debian.

ps: Same issue with /dev/zero, /dev/full, and also /dev/clipboard.

--
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

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019