summaryrefslogtreecommitdiffstats
path: root/libnetdata
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-13 17:16:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2023-02-13 17:16:02 +0000
commit396c327fe40b1db11fc204d7ae7ace84503de681 (patch)
tree6718eb5d5dcf3c6e3c93e32ac6ac9a857f6ca56e /libnetdata
parentReleasing debian version 1.38.0-1. (diff)
downloadnetdata-396c327fe40b1db11fc204d7ae7ace84503de681.tar.xz
netdata-396c327fe40b1db11fc204d7ae7ace84503de681.zip
Merging upstream version 1.38.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'libnetdata')
-rw-r--r--libnetdata/libnetdata.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/libnetdata/libnetdata.c b/libnetdata/libnetdata.c
index f6b6b026..666344a9 100644
--- a/libnetdata/libnetdata.c
+++ b/libnetdata/libnetdata.c
@@ -2011,21 +2011,24 @@ void for_each_open_fd(OPEN_FD_ACTION action, OPEN_FD_EXCLUDE excluded_fds){
if(!(excluded_fds & OPEN_FD_EXCLUDE_STDIN)) (void)close(STDIN_FILENO);
if(!(excluded_fds & OPEN_FD_EXCLUDE_STDOUT)) (void)close(STDOUT_FILENO);
if(!(excluded_fds & OPEN_FD_EXCLUDE_STDERR)) (void)close(STDERR_FILENO);
+#if defined(HAVE_CLOSE_RANGE)
+ if(close_range(STDERR_FILENO + 1, ~0U, 0) == 0) return;
+ error("close_range() failed, will try to close fds one by one");
+#endif
break;
case OPEN_FD_ACTION_FD_CLOEXEC:
if(!(excluded_fds & OPEN_FD_EXCLUDE_STDIN)) (void)fcntl(STDIN_FILENO, F_SETFD, FD_CLOEXEC);
if(!(excluded_fds & OPEN_FD_EXCLUDE_STDOUT)) (void)fcntl(STDOUT_FILENO, F_SETFD, FD_CLOEXEC);
if(!(excluded_fds & OPEN_FD_EXCLUDE_STDERR)) (void)fcntl(STDERR_FILENO, F_SETFD, FD_CLOEXEC);
+#if defined(HAVE_CLOSE_RANGE) && defined(CLOSE_RANGE_CLOEXEC) // Linux >= 5.11, FreeBSD >= 13.1
+ if(close_range(STDERR_FILENO + 1, ~0U, CLOSE_RANGE_CLOEXEC) == 0) return;
+ error("close_range() failed, will try to mark fds for closing one by one");
+#endif
break;
default:
break; // do nothing
}
-#if defined(HAVE_CLOSE_RANGE)
- if(close_range(STDERR_FILENO + 1, ~0U, (action == OPEN_FD_ACTION_FD_CLOEXEC ? CLOSE_RANGE_CLOEXEC : 0)) == 0) return;
- error("close_range() failed, will try to close fds manually");
-#endif
-
DIR *dir = opendir("/proc/self/fd");
if (dir == NULL) {
struct rlimit rl;