From 5d61a512d1eb2533697b4b7e9adf71b34e36fe29 Mon Sep 17 00:00:00 2001
From: "J. Lewis Muir"
If EPICS Base is built with readline support, any IOC that calls epicsExit() +from a thread other than the main thread is likely to leave the user's terminal +in a weird state, requiring the user to run something like 'stty sane' to clean +it up. This release patches the readline support code to clean up automatically +by registering an epicsAtExit() routine.
+ +The ao record type now checks converted raw values and limits them to the diff --git a/src/libCom/osi/os/default/epicsReadline.c b/src/libCom/osi/os/default/epicsReadline.c index 6c442e376..1d7d9c1d5 100644 --- a/src/libCom/osi/os/default/epicsReadline.c +++ b/src/libCom/osi/os/default/epicsReadline.c @@ -14,6 +14,7 @@ #define epicsExportSharedSymbols #include "envDefs.h" +#include "epicsExit.h" #include "epicsReadline.h" #define EPICS_COMMANDLINE_LIBRARY_EPICS 0 @@ -84,6 +85,14 @@ struct readlineContext { char *line; }; +static enum {rlNone, rlIdle, rlBusy} rlState = rlNone; + +static void rlExit(void *dummy) { + if (rlState == rlBusy) + rl_cleanup_after_signal(); +} + + /* * Create a command-line context */ @@ -92,6 +101,11 @@ epicsReadlineBegin(FILE *in) { struct readlineContext *readlineContext; + if (rlState == rlNone) { + epicsAtExit(rlExit, NULL); + rlState = rlIdle; + } + readlineContext = malloc(sizeof *readlineContext); if (readlineContext != NULL) { readlineContext->in = in; @@ -124,7 +138,9 @@ epicsReadline (const char *prompt, void *context) free (readlineContext->line); readlineContext->line = NULL; if (readlineContext->in == NULL) { + rlState = rlBusy; line = readline (prompt); + rlState = rlIdle; } else { line = (char *)malloc (linesize * sizeof *line);