Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-26 Thread Maxime Henrion
Terry Lambert wrote: Stefan Farfeleder wrote: On Mon, Nov 24, 2003 at 07:05:02PM +0100, boyd, rounin wrote: From: Jacques A. Vidrine [EMAIL PROTECTED] The application is broken. You must only check errno if you get an error indication from the library call. errno is only

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-26 Thread boyd, rounin
Wrong, strtol() can set errno in two cases, when the value is outside the range of representable values or when no conversion could be performed. well 'natch. it's trying to do math.h style hacks and overloads errno. iirc those sorts of things stem from V6/V7 on the PDP/11 when you may have

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-26 Thread Terry Lambert
Maxime Henrion wrote: Terry Lambert wrote: Wrong, counter-example: strtol(). Wrong; the standard specifies that the errno shall only be checked when the return value is -1. The exception in the strtol() case is only for presetting errno to 0 before you make the call, and making a

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-25 Thread boyd, rounin
From: Stefan Farfeleder [EMAIL PROTECTED] errno is meaningful for syscalls after an error (the original message). The fact that other functions also dink with errno is not relevant to that statement. I read boyd's statement as a contradiction to Jacques' one (only after syscall error

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-25 Thread Poul-Henning Kamp
In message [EMAIL PROTECTED], boyd, rounin write s: From: Stefan Farfeleder [EMAIL PROTECTED] errno is meaningful for syscalls after an error (the original message). The fact that other functions also dink with errno is not relevant to that statement. I read boyd's statement as a

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-25 Thread Enache Adrian
On Mon, Nov 24, 2003 a.d., Jacques A. Vidrine wrote: The application is broken. You must only check errno if you get an error indication from the library call. Sorry, but I don't see your point. I know when to check for errno. If you took the little illustrating program for a real life example

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-25 Thread Daniel Eischen
On Tue, 25 Nov 2003, Enache Adrian wrote: On Mon, Nov 24, 2003 a.d., Jacques A. Vidrine wrote: The application is broken. You must only check errno if you get an error indication from the library call. Sorry, but I don't see your point. I know when to check for errno. If you took the

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-25 Thread Jacques A. Vidrine
On Tue, Nov 25, 2003 at 04:46:24PM +0200, Enache Adrian wrote: On Mon, Nov 24, 2003 a.d., Jacques A. Vidrine wrote: The application is broken. You must only check errno if you get an error indication from the library call. Sorry, but I don't see your point. I know when to check for errno.

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-25 Thread Terry Lambert
Stefan Farfeleder wrote: On Mon, Nov 24, 2003 at 07:05:02PM +0100, boyd, rounin wrote: From: Jacques A. Vidrine [EMAIL PROTECTED] The application is broken. You must only check errno if you get an error indication from the library call. errno is only meaningful after a syscall error.

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-24 Thread Jacques A. Vidrine
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);

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-24 Thread boyd, rounin
From: Jacques A. Vidrine [EMAIL PROTECTED] The application is broken. You must only check errno if you get an error indication from the library call. errno is only meaningful after a syscall error. it is also well known that stdio uses isatty(3) (or equivelant) that may set errno to ENOTTY.

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-24 Thread Stefan Farfeleder
On Mon, Nov 24, 2003 at 07:05:02PM +0100, boyd, rounin wrote: From: Jacques A. Vidrine [EMAIL PROTECTED] The application is broken. You must only check errno if you get an error indication from the library call. errno is only meaningful after a syscall error. Wrong, counter-example:

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-24 Thread M. Warner Losh
In message: [EMAIL PROTECTED] Stefan Farfeleder [EMAIL PROTECTED] writes: : On Mon, Nov 24, 2003 at 07:05:02PM +0100, boyd, rounin wrote: : From: Jacques A. Vidrine [EMAIL PROTECTED] : The application is broken. You must only check errno if you get an : error indication from the

Re: [PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-24 Thread Stefan Farfeleder
On Mon, Nov 24, 2003 at 03:33:49PM -0700, M. Warner Losh wrote: In message: [EMAIL PROTECTED] Stefan Farfeleder [EMAIL PROTECTED] writes: : On Mon, Nov 24, 2003 at 07:05:02PM +0100, boyd, rounin wrote: : From: Jacques A. Vidrine [EMAIL PROTECTED] : The application is broken.

[PATCH] libc_r bug: successful close(2) sets errno to ENOTTY

2003-11-23 Thread Enache Adrian
$ 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