[BusyBox] Re: ifconfig: Clean up. [PATCH]
Glenn L. McGrath
bug1 at iinet.net.au
Wed Jul 27 00:03:06 UTC 2005
On Tue, 26 Jul 2005 11:53:24 -0400
Paul Fox <pgf at brightstareng.com> wrote:
> > > > + if (CONFIG_FEATURE_CLEAN_UP) close(sockfd);
> > > > return goterr;
> > > > }
> > >
> > > What is this supposed to accomplish, besides inflating the binary
> > > for no reason?
> >
> > If CLEAN_UP is undefined, it shouldn't affect the binary size at
> > all. If CLEAN_UP is defined, it cleans up the resources the applet
> > has allocated, namely file descriptors in this case.
>
> and why do we care about closing file descriptors?
We should be closing and checking the return value of close. I was going
to jump on this problem at one time for the archiving code, but i never
got around to it.
>From man close(2)
"Not checking the return value of close is a common but nevertheless
serious programming error. It is quite possible that errors on a
previous write(2) operation are first reported at the final close.
Not checking the return value when closing the file may lead to silent
loss of data. This can especially be observed with NFS and with disk
quota."
Glenn
More information about the busybox
mailing list