Re: Close() in daemon loop

From: David Luyer <david_luyer@dont-contact.us>
Date: Fri, 07 Jul 2000 08:33:44 +1000

> A little more: further up in main, there is a loop:
>
> if (opt_catch_signals)
> for (n = Squid_MaxFD; n > 2; n--)
> close(n);
>
> My question is: why does this (very similar) loop stop at 3, and the other
> start at 0, instead of 3?

While it seems like stating the obvious, in case you don't realise,
FD 0 = STDIN, FD 1 = STDOUT, FD 2 = STDERR.

However it should be valid to close all of them.

Also, the general close all valid FDs loop is fairly common in Unix.

David.

-- 
----------------------------------------------
David Luyer
Senior Network Engineer
Pacific Internet (Aust) Pty Ltd
Phone:  +61 3 9674 7525
Fax:    +61 3 9699 8693
Mobile: +61 4 1064 2258, +61 4 1114 2258
http://www.pacific.net.au        NASDAQ: PCNTF
<< fast 'n easy >>
----------------------------------------------
Received on Thu Jul 06 2000 - 16:33:53 MDT

This archive was generated by hypermail pre-2.1.9 : Tue Dec 09 2003 - 16:12:31 MST