diff options
| author | Alexander Couzens | 2023-10-23 14:54:28 +0000 |
|---|---|---|
| committer | David Bauer | 2025-05-31 20:41:00 +0000 |
| commit | c71c0f3e463a89615b302241bb1f2eab164ef14b (patch) | |
| tree | dfce825cbc200a225a4cff3c52ca5875cdeb0100 | |
| parent | a933061911aa4c49e953af618c3fb02ce6014142 (diff) | |
| download | uqmi-c71c0f3e463a89615b302241bb1f2eab164ef14b.tar.gz | |
common/utils: add system_fd_set_cloexec()
Will be used by uqmid/ubus interface.
Taken from netifd/ubus interface.
Signed-off-by: Alexander Couzens <lynxis@fe80.eu>
| -rw-r--r-- | common/utils.c | 11 | ||||
| -rw-r--r-- | common/utils.h | 1 |
2 files changed, 11 insertions, 1 deletions
diff --git a/common/utils.c b/common/utils.c index 3a2681d..bd4cb4f 100644 --- a/common/utils.c +++ b/common/utils.c @@ -19,11 +19,13 @@ * Boston, MA 02110-1301 USA. */ +#include <fcntl.h> +#include <libubox/utils.h> + #include "utils.h" #include "qmi-errors.h" #include <qmi-errors.c> -#include <libubox/utils.h> const char *qmi_get_error_str(int code) { @@ -36,3 +38,10 @@ const char *qmi_get_error_str(int code) return "Unknown error"; } + +void system_fd_set_cloexec(int fd) +{ +#ifdef FD_CLOEXEC + fcntl(fd, F_SETFD, fcntl(fd, F_GETFD) | FD_CLOEXEC); +#endif +} diff --git a/common/utils.h b/common/utils.h index d7b7947..aeed5ec 100644 --- a/common/utils.h +++ b/common/utils.h @@ -24,5 +24,6 @@ #define __UTILS_H const char *qmi_get_error_str(int code); +void system_fd_set_cloexec(int fd); #endif /* __UTILS_H */ |