This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Python throws error when closing /dev/urandom


> 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. ÂIf you don't read from the file there is no error upon
>> closing.
>>
>> $ python
>> Python 2.5.2 (r252:60911, Dec Â2 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 = open("/dev/urandom")
>> .>>> f.close()
>>
>> Note: no problem just opening and closing the special file. ÂBut:
>>
>> .>>> f = open("/dev/urandom")
>> .>>> f.read(8)
>> '\xf9"\xb7\'E\xf8Q\xa0'
>> .>>> f.close()
>> Traceback (most recent call last):
>> ÂFile "<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) {
> ÂFILE *f = 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.

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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]