Commit aa6cc04
committed
rpmSetCloseOnExec: use getrlimit()
In case /proc is not available to get the actual list of opened fds,
we fall back to iterating the list of all possible fds.
It is possible that during the course of the program execution the limit
on number of open file descriptors might be lowered, so using the
current limit, as returned by sysconf(_SC_OPEN_MAX), might omit some
fds. Therefore, use rlim_max from the structure filled in by
gertlimit(RLIMIT_NOFILE) to make sure we're checking all fds.
This slows down the function, but only in the case /proc is not
available, which should be rare in practice.
Signed-off-by: Kir Kolyshkin <[email protected]>1 parent e01f944 commit aa6cc04
1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
| 6 | + | |
6 | 7 | | |
7 | 8 | | |
8 | 9 | | |
| |||
39 | 40 | | |
40 | 41 | | |
41 | 42 | | |
42 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
43 | 50 | | |
44 | 51 | | |
45 | 52 | | |
| |||
0 commit comments