Re: [PATCH 4/7] build: add infrastructure for using close_range()/closefrom()

Subject: Re: [PATCH 4/7] build: add infrastructure for using close_range()/closefrom()

Date: Sun, 25 Jan 2026 10:29:20 +0100

To: notmuch@notmuchmail.org, David Bremner

Cc:

From: Anton Khirnov


Quoting David Bremner (2026-01-25 01:27:46)
> Anton Khirnov <anton@khirnov.net> writes:
> 
> > +void
> > +closefrom (int lowfd)
> > +{
> > +    for (int i = lowfd; i < 1024; i++)
> > +	close (i);
> > +}
> 
> Maybe I'm revealing my ignorance, but I feel like the magic number 1024
> deserves an explanation?

It's the maximum FD value accepted by select(), and for that reason it
is also the traditional upper bound on open file descriptors
(ulimit -n).

I'll add a comment to this effect to the code.

-- 
Anton Khirnov
_______________________________________________
notmuch mailing list -- notmuch@notmuchmail.org
To unsubscribe send an email to notmuch-leave@notmuchmail.org

Thread: