delorie.com/archives/browse.cgi | search |
Date: | Sun, 11 Feb 2001 21:23:26 +0200 |
From: | "Eli Zaretskii" <eliz AT is DOT elta DOT co DOT il> |
Sender: | halo1 AT zahav DOT net DOT il |
To: | "Mark E." <snowball3 AT bigfoot DOT com> |
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 |
> From: "Mark E." <snowball3 AT bigfoot DOT com> > Date: Sun, 11 Feb 2001 13:58:44 -0500 > > This program prints out a "file not found" message even when fd != -1. > > #include <fcntl.h> > #include <stdlib.h> > #include <sys/stat.h> > #include <errno.h> > > 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.
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |