|
a/src/utils/closefrom.cpp |
|
b/src/utils/closefrom.cpp |
|
... |
|
... |
26 |
*
|
26 |
*
|
27 |
* There are many reasons for closing file descriptors before
|
27 |
* There are many reasons for closing file descriptors before
|
28 |
* an exec (security, pipe control, the possibility that a bug will trigger
|
28 |
* an exec (security, pipe control, the possibility that a bug will trigger
|
29 |
* an unwanted write, etc.)
|
29 |
* an unwanted write, etc.)
|
30 |
*
|
30 |
*
|
31 |
* A process has currently no POSIX way to determine the list of open file
|
31 |
* A process has currently no POSIX way to determine the set of open file
|
32 |
* descriptors or at least the highest value. Closing all files (except a few),
|
32 |
* descriptors or at least the highest value. Closing all files (except a few),
|
33 |
* thus implies performing a close() system call on each entry up to the
|
33 |
* thus implies performing a close() system call on each entry up to the
|
34 |
* maximum, which can be both relatively difficult to determine, and quite
|
34 |
* maximum, which can be both relatively difficult to determine, and quite
|
35 |
* high (ie: several thousands), incurring a non-negligible cost.
|
35 |
* high (ie: several thousands), incurring a non-negligible cost.
|
36 |
*
|
36 |
*
|
|
... |
|
... |
44 |
* getting-the-highest-allocated-file-descriptor
|
44 |
* getting-the-highest-allocated-file-descriptor
|
45 |
*
|
45 |
*
|
46 |
* System interfaces:
|
46 |
* System interfaces:
|
47 |
* FreeBSD:
|
47 |
* FreeBSD:
|
48 |
* - Has a closefrom() system call as of release 7.x around Sep 2009
|
48 |
* - Has a closefrom() system call as of release 7.x around Sep 2009
|
49 |
* - Has a /dev/fd, directory which lists the current process' open
|
49 |
* - Has a /dev/fd, directory which shows the current process' open
|
50 |
* descriptors. Only descriptors 0, 1, 2 are shown except if
|
50 |
* descriptors. Only descriptors 0, 1, 2 are shown except if
|
51 |
* fdescfs is mounted which it is not by default
|
51 |
* fdescfs is mounted which it is not by default
|
52 |
*
|
52 |
*
|
53 |
* Interface:
|
53 |
* Interface:
|
54 |
* int libclf_closefrom(fd)
|
54 |
* int libclf_closefrom(fd)
|