From 4dbce1a0aa57e1712d6e0166b428ecdd59b44f3c Mon Sep 17 00:00:00 2001 From: Mike Black W9MDB Date: Sun, 2 Oct 2022 08:06:50 -0500 Subject: [PATCH] Add setvbuf to rigctl.c and rigctld.d to overcome non-buffering of stderr on mingw builds. Should also speed up other OS's too since only 1 flush will be executed instead of 2 --- tests/rigctl.c | 4 ++++ tests/rigctld.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/tests/rigctl.c b/tests/rigctl.c index c90064686..8adc9c34e 100644 --- a/tests/rigctl.c +++ b/tests/rigctl.c @@ -151,6 +151,10 @@ int main(int argc, char *argv[]) int ext_resp = 0; int i; char rigstartup[1024]; + char vbuf[1024]; + + int err = setvbuf(stderr, vbuf, _IOFBF, sizeof(vbuf)); + if (err) rig_debug(RIG_DEBUG_ERR, "%s: setvbuf err=%s\n", __func__, strerror(err)); while (1) { diff --git a/tests/rigctld.c b/tests/rigctld.c index 364569a64..5686a2929 100644 --- a/tests/rigctld.c +++ b/tests/rigctld.c @@ -267,6 +267,7 @@ int main(int argc, char *argv[]) char host[NI_MAXHOST]; char serv[NI_MAXSERV]; char rigstartup[1024]; + char vbuf[1024]; #if HAVE_SIGACTION struct sigaction act; #endif @@ -282,6 +283,10 @@ int main(int argc, char *argv[]) is_rigctld = 1; + int err = setvbuf(stderr, vbuf, _IOFBF, sizeof(vbuf)); + if (err) rig_debug(RIG_DEBUG_ERR, "%s: setvbuf err=%s\n", __func__, strerror(err)); + + while (1) { int c;