cronie-crond / cronie

Cronie cron daemon project
Other
467 stars 80 forks source link

If nofile limit is big, the close of FDs will take time #152

Closed bwelterl closed 12 months ago

bwelterl commented 1 year ago

Hello,

In do_command.c, if nofile limit is high, the close of all FDs until the limit will take time:

                        int fd, fdmax = TMIN(getdtablesize(), MAX_CLOSE_FD);

                                /* close all unwanted open file descriptors */
                                for(fd = STDERR + 1; fd < fdmax; fd++) {
                                        close(fd);
                                }

We can use the FD in /proc/self/fd to optmize.

A tested the code available in this PR: https://github.com/cronie-crond/cronie/pull/151

Thank you !

Benoit