diff options
author | Dim-P <Dim-P@users.noreply.github.com> | 2023-01-19 12:01:02 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-19 12:01:02 +0000 |
commit | 8ee7e8b26162c1c29e46c8894903b57d7bbd687f (patch) | |
tree | daee30f6f2496446bd06539a317aba52a1de8568 /libnetdata/libnetdata.h | |
parent | c1908d3163185cf65a139edeb11a165a10eca1e9 (diff) |
Improve file descriptor closing loops (#14213)
* Add for_each_open_fd() and fix second instance of _SC_OPEN_MAX
* Add argument to allow exclusion of file descriptors from closing
* Fix clang error
* Address review comments
* Use close_range() if possible and replace macros with enums
Diffstat (limited to 'libnetdata/libnetdata.h')
-rw-r--r-- | libnetdata/libnetdata.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libnetdata/libnetdata.h b/libnetdata/libnetdata.h index 7a7fe032ff..56d984dec5 100644 --- a/libnetdata/libnetdata.h +++ b/libnetdata/libnetdata.h @@ -432,6 +432,17 @@ static inline char *get_word(char **words, size_t num_words, size_t index) { bool run_command_and_copy_output_to_stdout(const char *command, int max_line_length); +typedef enum { + OPEN_FD_ACTION_CLOSE, + OPEN_FD_ACTION_FD_CLOEXEC +} OPEN_FD_ACTION; +typedef enum { + OPEN_FD_EXCLUDE_STDIN = 0x01, + OPEN_FD_EXCLUDE_STDOUT = 0x02, + OPEN_FD_EXCLUDE_STDERR = 0x04 +} OPEN_FD_EXCLUDE; +void for_each_open_fd(OPEN_FD_ACTION action, OPEN_FD_EXCLUDE excluded_fds); + void netdata_cleanup_and_exit(int ret) NORETURN; void send_statistics(const char *action, const char *action_result, const char *action_data); extern char *netdata_configured_host_prefix; |