_cleanup() vs Linux fcloseall()

Claus Assmann freebsd+current at esmtp.org
Thu Mar 30 15:22:02 UTC 2006


On Thu, Mar 30, 2006, Peter Jeremy wrote:

> I'd prefer to see a function that closed all file descriptors greater
> than a specified limit (which makes it easy for a process to preserve
> stdin/out/err but close everything else).  Two obvious places for this

closefrom(), see SunOS 5.10 et.al:
Standard C Library Functions                        closefrom(3C)

NAME
     closefrom, fdwalk - close or iterate over open file descrip-
     tors

SYNOPSIS
     #include <stdlib.h>

     void closefrom(int  lowfd);

     int fdwalk(int (*func)(void *, int), void *cd);

DESCRIPTION
     The closefrom() function calls close(2)  on  all  open  file
     descriptors greater than or equal to lowfd.



More information about the freebsd-current mailing list