* errno reset when using thread enabled gcc @ 2002-10-17 0:13 Anurag Sharma 2002-10-17 7:15 ` Igor Pechtchanski 0 siblings, 1 reply; 3+ messages in thread From: Anurag Sharma @ 2002-10-17 0:13 UTC (permalink / raw) To: cygwin 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/ ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: errno reset when using thread enabled gcc 2002-10-17 0:13 errno reset when using thread enabled gcc Anurag Sharma @ 2002-10-17 7:15 ` Igor Pechtchanski 2002-10-17 18:26 ` Anurag Sharma 0 siblings, 1 reply; 3+ messages in thread From: Igor Pechtchanski @ 2002-10-17 7:15 UTC (permalink / raw) To: Anurag Sharma; +Cc: cygwin On Thu, 17 Oct 2002, Anurag Sharma wrote: > 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 Anurag, While I don't know for sure that this is what's happening, have you considered that operator<< or endl may (re)set errno? Igor -- http://cs.nyu.edu/~pechtcha/ |\ _,,,---,,_ pechtcha@cs.nyu.edu ZZZzz /,`.-'`' -. ;-;;,_ igor@watson.ibm.com |,4- ) )-,_. ,\ ( `'-' Igor Pechtchanski '---''(_/--' `-'\_) fL a.k.a JaguaR-R-R-r-r-r-.-.-. Meow! "Water molecules expand as they grow warmer" (C) Popular Science, Oct'02, p.51 -- 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/ ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: errno reset when using thread enabled gcc 2002-10-17 7:15 ` Igor Pechtchanski @ 2002-10-17 18:26 ` Anurag Sharma 0 siblings, 0 replies; 3+ messages in thread From: Anurag Sharma @ 2002-10-17 18:26 UTC (permalink / raw) To: cygwin On Thu, 17 Oct 2002 10:09:26 -0400 (EDT) Igor Pechtchanski <pechtcha@cs.nyu.edu> wrote: > On Thu, 17 Oct 2002, Anurag Sharma wrote: > > > 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 > > Anurag, > > While I don't know for sure that this is what's happening, have you > considered that operator<< or endl may (re)set errno? > Igor Yes Igor, It is the STL iostream operators which are resetting it. Using the threading model of posix does make the STL thread safe, but why should it affect errno? Thanks for your response. Reagrds, 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/ ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2002-10-18 0:32 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2002-10-17 0:13 errno reset when using thread enabled gcc Anurag Sharma 2002-10-17 7:15 ` Igor Pechtchanski 2002-10-17 18:26 ` Anurag Sharma
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).