Date: Sun, 11 Feb 2001 21:23:26 +0200 From: "Eli Zaretskii" Sender: halo1 AT zahav DOT net DOT il To: "Mark E." Message-Id: <8011-Sun11Feb2001212326+0200-eliz@is.elta.co.il> X-Mailer: Emacs 20.6 (via feedmail 8.3.emacs20_6 I) and Blat ver 1.8.6 CC: djgpp-workers AT delorie DOT com In-reply-to: <3A869A94.27606.A30709@localhost> (snowball3@bigfoot.com) Subject: Re: preserve errno in open patch References: <3A869A94 DOT 27606 DOT A30709 AT localhost> Reply-To: djgpp-workers AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp-workers AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > From: "Mark E." > Date: Sun, 11 Feb 2001 13:58:44 -0500 > > This program prints out a "file not found" message even when fd != -1. > > #include > #include > #include > #include > > int main() > { > int fd; > > fd = open("file", O_RDWR | O_CREAT | O_TRUNC, S_IWUSR); > > if (errno) > perror("file"); > > close(fd); > > return 0; > } This is not a bug: `open' is not an atomic system call, so it is perfectly valid for it to set errno to something non-zero. That said, I have no objections to the change, if it useful in some situation.