On Sun, Nov 23, 2003 at 04:14:08PM +0200, Enache Adrian wrote: > $ cc close.c -o close && ./close > 0 > 0 > > $ cc close.c -lc_r -o close && ./close > 0 > 25 > > $ cat close.c > #include <errno.h> > main() > { > int fd = open("/dev/null", 1); > printf("%d\n", errno); > close(fd); > printf("%d\n", errno); > } > > This confuses rather badly applications which assume errno is meaningful. The application is broken. You must only check errno if you get an error indication from the library call. <URL:http://www.opengroup.org/onlinepubs/007904975/functions/errno.html> IEEE Std 1003.1, 2003 Edition says, in part: ``The value of errno should only be examined when it is indicated to be valid by a function's return value.'' Cheers, -- Jacques Vidrine NTT/Verio SME FreeBSD UNIX Heimdal nectar_at_celabo.org jvidrine_at_verio.net nectar_at_freebsd.org nectar_at_kth.seReceived on Mon Nov 24 2003 - 08:44:59 UTC
This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:30 UTC