Is it considered to be ok to not check the return code of close(2) in base?

Ian Lepore ian at freebsd.org
Sat Jan 6 01:11:03 UTC 2018


On Fri, 2018-01-05 at 15:17 -0800, Conrad Meyer wrote:
> On Fri, Jan 5, 2018 at 2:34 PM, Poul-Henning Kamp <phk at phk.freebsd.dk
> > wrote:
> > 
> > Brookes suggestion, while well intentioned, wouldn't get very far,
> > because it is common for shells and shell-like programs to do:
> > 
> >         for (i = 3; i < ALOT; i++)
> >                 (void)close(i);
> > 
> > To get rid of unwanted filedescriptors from syslog(3), getpwent(3)
> > etc.
> > in the child process.
> > 
> > Yes, I know about closefrom(2), but a lot of programs still don't
> > use it.
> Hi,
> 
> That seems like a good way to quickly identify programs in base that
> still do not use closefrom().
> 
> Best,
> Conrad
> 

Portable programs MUST iterate 3-ALOT, because closefrom() is not
available in linux and other OSes.

-- Ian


More information about the freebsd-hackers mailing list