Subject: Re: closefrom()
To: None <tech-userlevel@netbsd.org>
From: Matt Thomas <matt@3am-software.com>
List: tech-userlevel
Date: 05/26/2004 15:39:03
At 02:48 PM 5/26/2004, mouss wrote:
>Klaus Klein (by way of Klaus Klein <kleink@mibh.de>) wrote:
>>I agree.  However, what's the rationale behind its declaration
>>having ended up in <stdlib.h>?  I won't contend that Solaris'
>>is prior art, but since <stdlib.h> rarely concerns itself with
>>file descriptor management, OpenBSD's in <unistd.h> seems a
>>more natural choice of placement to me, but it's also unnecessarily
>>diverging.
>
>both unistd and stdlib have their history of portability issues, and none 
>seems better from a "rational" viewpoint. so the winner is the first that 
>had it... the argument stating that stdlib is std and should be reserved 
>to std c has history against it...

stdlib.h includes non O/S specific interfaces (malloc, free, getopt).
closefrom is definitely O/S specific (Unix-Like), so it doesn't
belong there.

>Now, whether it goes to unistd, stdlib, newstandard.h or 
>hasta_siempre_la_revolution.h is a secondary question. The header files 
>mechanism is one the (archaic?) C "features" that causes too many problems 
>and should deserve very little time.

It's easy to look back and say header files are dumb.  But that was 30
(or 15 depending on your view) years and the computing world was very
very different.  Hindsight is easy, foresight is not.

>so go add it. just put the declaration in any header file you feel good.

I strong disagree.  <unistd.h> is a better choice since that's where
open/close/dup live.


-- 
Matt Thomas                     email: matt@3am-software.com
3am Software Foundry              www: http://3am-software.com/bio/matt/
Cupertino, CA              disclaimer: I avow all knowledge of this message.