[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: /usr/lib/apt/methods/http - close(-1)



On 29 Jan 1999, Stephen Zander wrote:

> >>>>> "Scott" == Scott K Ellis <storm@stormcrow.org> writes:
> 
>     Scott> On Fri, 29 Jan 1999, Russell Coker wrote:
>     >> What is a close(-1) supposed to do?  The http program does one
>     >> and I'm curious as to why...
> 
>     Scott> IIRC, close(-1) closes all open file handles.  I'm not
>     Scott> certain exactly wher this is documented though.
> 
> Actually, it shouldn't do anything.  What's most likely is the source
> has multiple code paths after the opening of some file descriptor &
> rather than do error checking in each code path, the programmer
> elected to to close the file descriptor just prior to exiting that
> block of code.  When the open fails for hatever reason, the return
> code from open/socket/whatever is -1.
> 
> IOW, close (-1) is an ignorable non-op (unless, of course, you were
> trying to get to the previous value of errno :))

Okay, so I didn't recall correctly :)


Reply to: