Re: Help

John Reiser <[email protected]> Thu, 7 Sep 2023 07:52:33 -0700
Newsgroups gmane.comp.debugging.valgrind
Message-ID <[email protected]>
> ==17348== Warning: invalid file descriptor 1024 in syscall close()
> 
> Your exe is probably trying to ensure all file descriptors are closed. You should probably use getrlimit() to query the upper limit rather than assume anything. Exes under Valgrind have a slighly lower limit because Valgrind uses some file descriptors itself (e.g., its log file).

See also the manual page for 'close_range', which is a system call in Linux >= 5.9 and FreeBSD.
You may have to think about what the parameters should be, but 'close_range' is very efficient.