errno reset when using thread enabled gcc

Anurag Sharma anurag@proximity.com.au
Thu Oct 17 00:13:00 GMT 2002


Hi All,

I have come across a strange behaviour using native gcc on cygwin. I
understand that this issue is not 100% relevant to this list, but I am
hoping some one might have come across this issue before. Apologies for
any incovinience. I have posted the same on newlib mailing list too.

Consider this short code:

   int fd = ::open("/tmp/errnotest", O_RDONLY | O_BINARY);
    
    if (fd == -1) {
	std::cerr << "open failed, errno=" << errno << ", strerror=" <<
strerror(errno) << std::endl;
	std::cerr << "open failed, errno=" << errno << ", strerror=" <<
strerror(errno) << std::endl;
    }

If I build the gcc compiler by providing --enable-threads=single option
in the configure stage, following is the output :

open failed, errno=2, strerror=No such file or directory
open failed, errno=2, strerror=No such file or directory
 
This is of course expected.

Hoewever if I build the compiler by providing --enable-threads=posix
option in the configure stage, the output is as follows :

open failed, errno=2, strerror=No such file or directory
open failed, errno=0, strerror=No error

That is , after the first call to errno, it is reset!!

Has anyone else experiened this before? Can anyone please help find out
what exactly is going wrong?

Regards,

Anurag

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/



More information about the Cygwin mailing list