From ef77f1c71f58834cc497610431c93b1038b0126e Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 26 Dec 2021 07:27:38 -0600 Subject: [PATCH] Fix pipe NONBLOCK flags in iofunc.c -- was not being applied to both file descriptors https://github.com/Hamlib/Hamlib/issues/902 --- src/iofunc.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/iofunc.c b/src/iofunc.c index 8fbb8eb5d..9e105c34d 100644 --- a/src/iofunc.c +++ b/src/iofunc.c @@ -108,7 +108,13 @@ int HAMLIB_API port_open(hamlib_port_t *p) flags |= O_NONBLOCK; if (fcntl(sync_pipe_fds[0], F_SETFL, flags)) { - rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on pipe=%s\n", __func__, strerror(errno)); + rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on sync_read=%s\n", __func__, strerror(errno)); + } + flags = fcntl(sync_pipe_fds[1], F_GETFL); + flags |= O_NONBLOCK; + if (fcntl(sync_pipe_fds[1], F_SETFL, flags)) + { + rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on sync_write=%s\n", __func__, strerror(errno)); } #endif if (status != 0) @@ -131,7 +137,13 @@ int HAMLIB_API port_open(hamlib_port_t *p) flags |= O_NONBLOCK; if (fcntl(sync_pipe_fds[0], F_SETFL, flags)) { - rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on pipe#2=%s\n", __func__, strerror(errno)); + rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on error_read=%s\n", __func__, strerror(errno)); + } + flags = fcntl(sync_pipe_fds[1], F_GETFL); + flags |= O_NONBLOCK; + if (fcntl(sync_pipe_fds[1], F_SETFL, flags)) + { + rig_debug(RIG_DEBUG_ERR, "%s: error setting O_NONBLOCK on error_write=%s\n", __func__, strerror(errno)); } #endif if (status != 0)