From 19048051031e2ca128047e5c8ea61da65df3942e Mon Sep 17 00:00:00 2001 From: Olof hagsand Date: Wed, 22 May 2024 16:47:39 +0200 Subject: [PATCH] Fixed: [Error message from CLI if terminal is modified](https://github.com/clicon/clixon-controller/issues/122) --- CHANGELOG.md | 1 + lib/src/clixon_proto.c | 27 +++++++++++++++++---------- 2 files changed, 18 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b058306..fa81dac5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -62,6 +62,7 @@ Developers may need to change their code ### Corrected Bugs +* Fixed: [Error message from CLI if terminal is modified](https://github.com/clicon/clixon-controller/issues/122) * Fixed: backend exit when receiving invalid NETCONF get select XPath * Added XML encoding to XPaths in `select` attribute * Fixed: Fail on return errors when reading from datastore diff --git a/lib/src/clixon_proto.c b/lib/src/clixon_proto.c index 997e2d52..b88dfafd 100644 --- a/lib/src/clixon_proto.c +++ b/lib/src/clixon_proto.c @@ -142,8 +142,8 @@ clixon_inet2sin(const char *addrtype, * Notaly this may an issue of RFC 3896 encoded strings */ struct clicon_msg * -clicon_msg_encode(uint32_t id, - const char *format, ...) +clicon_msg_encode(uint32_t id, + const char *format, ...) { va_list args; uint32_t xmllen; @@ -302,10 +302,13 @@ clicon_rpc_connect_inet(clixon_handle h, /*! Ensure all of data on socket comes through. fn is either read or write * + * Just called for read(2) * @param[in] fn I/O function, ie read/write * @param[in] fd File descriptor, eg socket * @param[in] s0 Buffer to read to or write from - * @param[in] n Number of bytes to read/write, loop until done + * @retval n Bytes written (see man 2 read) + * @retval 0 EOF + * @retval -1 Error */ static ssize_t atomicio(ssize_t (*fn) (int, void *, size_t), @@ -313,8 +316,9 @@ atomicio(ssize_t (*fn) (int, void *, size_t), void *s0, size_t n) { - char *s = s0; - ssize_t res, pos = 0; + char *s = s0; + ssize_t res; + ssize_t pos = 0; while (n > pos) { _atomicio_sig = 0; @@ -471,7 +475,7 @@ clixon_rpc10(int sock, cbuf *msgret, int *eof) { - int retval = -1; + int retval = -1; clixon_debug(CLIXON_DBG_MSG | CLIXON_DBG_DETAIL, ""); if (netconf_framing_preamble(NETCONF_SSH_EOM, msg) < 0) @@ -562,9 +566,12 @@ clixon_msg_rcv11(int s, if (intr){ if (clixon_signal_save(&oldsigset, oldsigaction) < 0) goto done; + set_signal(SIGINT, SIG_IGN, NULL); clicon_signal_unblock(SIGINT); set_signal_flags(SIGINT, 0, atomicio_sig_handler, NULL); + /* May be more signals to ignore */ + set_signal(SIGWINCH, SIG_IGN, NULL); } while (*eof == 0 && eom == 0) { /* Read input data from socket and append to cbbuf */ @@ -722,8 +729,8 @@ send_msg_notify(int s, const char *descr, char *msg) { - int retval = -1; - cbuf *cb = NULL; + int retval = -1; + cbuf *cb = NULL; if ((cb = cbuf_new()) == NULL){ clixon_err(OE_UNIX, errno, "cbuf_new"); @@ -755,8 +762,8 @@ send_msg_notify_xml(clixon_handle h, const char *descr, cxobj *xev) { - int retval = -1; - cbuf *cb = NULL; + int retval = -1; + cbuf *cb = NULL; if ((cb = cbuf_new()) == NULL){ clixon_err(OE_PLUGIN, errno, "cbuf_new");