Re: Close() in daemon loop

From: Duane Wessels <wessels@dont-contact.us>
Date: Thu, 6 Jul 2000 16:39:58 -0600

On Fri, 7 Jul 2000, Robert Collins wrote:

> 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?

The difference is that in the above case, Squid might not
become a daemon process, so we want stdout, stderr open for
debugging purposes.

In watch_child(), squid is becoming a daemon. Its standard
practice to close all descriptors when becoming a daemon
process.

If NT/cygwin requires FD 2 to remain open, then we can
work around it.
Received on Thu Jul 06 2000 - 16:40:11 MDT

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