diff options
author | Thomas Haller <thaller@redhat.com> | 2023-04-03 17:52:37 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2023-04-04 08:43:21 +0200 |
commit | ce414933a7bf8b52de4cf1990c96bc32af77b5d6 (patch) | |
tree | 57a42b4ea8caa446747ae193d8a40c0941490675 | |
parent | f4943e07f1ae89c97c1fca8469b846831cab4ef8 (diff) | |
download | NetworkManager-ce414933a7bf8b52de4cf1990c96bc32af77b5d6.tar.gz |
core: use nm_io_fcntl_setfl_update_nonblock() helper
-rw-r--r-- | src/core/nm-core-utils.c | 11 | ||||
-rw-r--r-- | src/libnmc-base/nm-polkit-listener.c | 8 |
2 files changed, 5 insertions, 14 deletions
diff --git a/src/core/nm-core-utils.c b/src/core/nm-core-utils.c index 4a028e8be2..6417cfc43f 100644 --- a/src/core/nm-core-utils.c +++ b/src/core/nm-core-utils.c @@ -5090,7 +5090,6 @@ nm_utils_spawn_helper(const char *const *args, gs_free_error GError *error = NULL; gs_free char *commands = NULL; HelperInfo *info; - int fd_flags; const char *const *arg; GMainContext *context; gsize n; @@ -5162,13 +5161,9 @@ nm_utils_spawn_helper(const char *const *args, nm_g_timeout_source_new_seconds(20, G_PRIORITY_DEFAULT, helper_timeout, info, NULL); g_source_attach(info->timeout_source, context); - /* Set file descriptors as non-blocking */ - fd_flags = fcntl(info->child_stdin, F_GETFL, 0); - fcntl(info->child_stdin, F_SETFL, fd_flags | O_NONBLOCK); - fd_flags = fcntl(info->child_stdout, F_GETFL, 0); - fcntl(info->child_stdout, F_SETFL, fd_flags | O_NONBLOCK); - fd_flags = fcntl(info->child_stderr, F_GETFL, 0); - fcntl(info->child_stderr, F_SETFL, fd_flags | O_NONBLOCK); + nm_io_fcntl_setfl_update_nonblock(info->child_stdin); + nm_io_fcntl_setfl_update_nonblock(info->child_stdout); + nm_io_fcntl_setfl_update_nonblock(info->child_stderr); /* Watch process stdin */ for (n = 1, arg = args; *arg; arg++) diff --git a/src/libnmc-base/nm-polkit-listener.c b/src/libnmc-base/nm-polkit-listener.c index 7b0de39bcb..c715b0494a 100644 --- a/src/libnmc-base/nm-polkit-listener.c +++ b/src/libnmc-base/nm-polkit-listener.c @@ -499,7 +499,6 @@ out: static void begin_authentication(AuthRequest *request) { - int fd_flags; const char *helper_argv[] = { POLKIT_AGENT_HELPER_1_PATH, request->username, @@ -534,11 +533,8 @@ begin_authentication(AuthRequest *request) return; } - fd_flags = fcntl(request->child_stdin, F_GETFL, 0); - fcntl(request->child_stdin, F_SETFL, fd_flags | O_NONBLOCK); - - fd_flags = fcntl(request->child_stdout, F_GETFL, 0); - fcntl(request->child_stdout, F_SETFL, fd_flags | O_NONBLOCK); + nm_io_fcntl_setfl_update_nonblock(request->child_stdin); + nm_io_fcntl_setfl_update_nonblock(request->child_stdout); request->child_stdout_watch_source = nm_g_unix_fd_source_new(request->child_stdout, G_IO_IN | G_IO_ERR | G_IO_HUP, |