libCom: Make readline support clean up on epicsExit()
This commit is contained in:
@@ -3,16 +3,29 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
|
||||
<title>EPICS Base R3.14.12.5 Release Notes</title>
|
||||
<title>EPICS Base R3.14.12.6 Release Notes</title>
|
||||
</head>
|
||||
|
||||
<body lang="en">
|
||||
<h1 align="center">EPICS Base Release 3.14.12.6</h1>
|
||||
|
||||
<h2 align="center">Changes between 3.14.12.5 and 3.14.12.6</h2>
|
||||
|
||||
<!-- Insert new items immediately below here ... -->
|
||||
|
||||
<h3>Clean up after GNU readline()</h3>
|
||||
|
||||
<p>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.</p>
|
||||
|
||||
|
||||
<h1 align="center">EPICS Base Release 3.14.12.5</h1>
|
||||
|
||||
<h2 align="center">Changes between 3.14.12.4 and 3.14.12.5</h2>
|
||||
|
||||
<!-- Insert new items immediately below here ... -->
|
||||
|
||||
<h3>aoRecord raw conversion overflows</h3>
|
||||
|
||||
<p>The ao record type now checks converted raw values and limits them to the
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user