There is a comment in omprog.c:

   /* we close all file handles as we fork soon
    * Is there a better way to do this? - mail me!  * [email protected]
    */

   for(i = 3 ; i <= 65535 ; ++i)
        close(i);

The better, not-portable, way is to open /proc/self/fd directory, read all
the entries and close exactly those file descriptors. Configure script should
check if /proc/self/fd exists and has the right contents. If it doesn't
exist, then check for /dev/fd directory.

Perhaps the check needs to be done in run-time, as well. IIRC, FreeBSD
doesn't eneble procfs by default, but it can be mounted by administrators
who wish to do so. I don't know if FreeBSD has /dev/fd.

If the above directory is not available, use getrlimit(RLIMIT_NOFILE) to
get the upper bound for the file descriptor numbers (it will be in the
soft limit field) and close them all in a loop. The limit will usually be
much lower than 65536.

-- 
 .-.   .-.    Yes, I am an agent of Satan, but my duties are largely
(_  \ /  _)   ceremonial.
     |
     |        [email protected]
_______________________________________________
rsyslog mailing list
http://lists.adiscon.net/mailman/listinfo/rsyslog
http://www.rsyslog.com

Reply via email to