delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2002/10/17/10:09:50

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/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
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Thu, 17 Oct 2002 10:09:26 -0400 (EDT)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Anurag Sharma <anurag AT proximity DOT com DOT au>
cc: cygwin AT cygwin DOT com
Subject: Re: errno reset when using thread enabled gcc
In-Reply-To: <20021017141643.0356fc8a.anurag@proximity.com.au>
Message-ID: <Pine.GSO.4.44.0210171008050.6818-100000@slinky.cs.nyu.edu>
Importance: Normal
MIME-Version: 1.0

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 AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT 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/

- Raw text -


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