diff --git a/documentation/RELEASE_NOTES.html b/documentation/RELEASE_NOTES.html
index 8534b27fe..0ed88c4a4 100644
--- a/documentation/RELEASE_NOTES.html
+++ b/documentation/RELEASE_NOTES.html
@@ -14,6 +14,18 @@
+
Fixed iocsh stream redirection for several commands
+
+A number of iocsh commands did not respond correctly to redirection of their
+output using the iocsh '>file' or '2>error-file' syntax, and redirecting an
+empty command could create files with garbage names. There may still be a few
+commands that do not properly redirect their output, please notify the core
+developers if you discover any. Thanks to Eric Norum for the iocsh changes.
+
+For externally developed commands, the simplest way to support redirection in
+your C/C++ code is to #include "epicsStdioRedirect.h" instead of
+stdio.h.
+
Fixed crash loading record instance of unknown type
Fixed segfault when dbLoadRecords tried to load a record of a type that was
diff --git a/src/ca/iocinf.cpp b/src/ca/iocinf.cpp
index 487067c00..b3e634928 100644
--- a/src/ca/iocinf.cpp
+++ b/src/ca/iocinf.cpp
@@ -22,12 +22,12 @@
#include
#include
-#include
#include
#include
#include "envDefs.h"
#include "epicsAssert.h"
+#include "epicsStdioRedirect.h"
#include "errlog.h"
#include "osiWireFormat.h"
diff --git a/src/ca/test_event.cpp b/src/ca/test_event.cpp
index 17cfe2f47..8b5a8bb54 100644
--- a/src/ca/test_event.cpp
+++ b/src/ca/test_event.cpp
@@ -14,7 +14,7 @@
* simple stub for testing monitors
*/
-#include
+#include "epicsStdioRedirect.h"
#define epicsExportSharedSymbols
#include "cadef.h"
diff --git a/src/libCom/gpHash/gpHashLib.c b/src/libCom/gpHash/gpHashLib.c
index 6a800531f..842f3b4de 100644
--- a/src/libCom/gpHash/gpHashLib.c
+++ b/src/libCom/gpHash/gpHashLib.c
@@ -9,8 +9,7 @@
/* $Revision-Id$ */
/* Author: Marty Kraimer Date: 04-07-94 */
-
-#include
+
#include
#include
#include
@@ -18,6 +17,7 @@
#define epicsExportSharedSymbols
#include "cantProceed.h"
#include "epicsMutex.h"
+#include "epicsStdioRedirect.h"
#include "epicsString.h"
#include "dbDefs.h"
#include "ellLib.h"
@@ -34,13 +34,14 @@ typedef struct gphPvt {
#define MIN_SIZE 256
#define DEFAULT_SIZE 512
#define MAX_SIZE 65536
-
+
+
void epicsShareAPI gphInitPvt(gphPvt **ppvt, int size)
{
gphPvt *pgphPvt;
if (size & (size - 1)) {
- printf("gphInitPvt: %d is not a power of 2\n", size);
+ fprintf(stderr, "gphInitPvt: %d is not a power of 2\n", size);
size = DEFAULT_SIZE;
}
@@ -88,7 +89,7 @@ GPHENTRY * epicsShareAPI gphFind(gphPvt *pgphPvt, const char *name, void *pvtid)
epicsMutexUnlock(pgphPvt->lock);
return pgphNode;
}
-
+
GPHENTRY * epicsShareAPI gphAdd(gphPvt *pgphPvt, const char *name, void *pvtid)
{
ELLLIST **paplist;
@@ -127,7 +128,7 @@ GPHENTRY * epicsShareAPI gphAdd(gphPvt *pgphPvt, const char *name, void *pvtid)
epicsMutexUnlock(pgphPvt->lock);
return (pgphNode);
}
-
+
void epicsShareAPI gphDelete(gphPvt *pgphPvt, const char *name, void *pvtid)
{
ELLLIST **paplist;
@@ -161,7 +162,7 @@ void epicsShareAPI gphDelete(gphPvt *pgphPvt, const char *name, void *pvtid)
epicsMutexUnlock(pgphPvt->lock);
return;
}
-
+
void epicsShareAPI gphFreeMem(gphPvt *pgphPvt)
{
ELLLIST **paplist;
@@ -203,9 +204,10 @@ void epicsShareAPI gphDumpFP(FILE *fp, gphPvt *pgphPvt)
ELLLIST **paplist;
int h;
- if (pgphPvt == NULL) return;
+ if (pgphPvt == NULL)
+ return;
- printf("Hash table has %d buckets", pgphPvt->size);
+ fprintf(fp, "Hash table has %d buckets", pgphPvt->size);
paplist = pgphPvt->paplist;
for (h = 0; h < pgphPvt->size; h++) {
diff --git a/src/libCom/iocsh/iocsh.cpp b/src/libCom/iocsh/iocsh.cpp
index c140e56a9..c1d50d27e 100644
--- a/src/libCom/iocsh/iocsh.cpp
+++ b/src/libCom/iocsh/iocsh.cpp
@@ -3,8 +3,7 @@
* National Laboratory.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
-* EPICS BASE Versions 3.13.7
-* and higher are distributed subject to a Software License Agreement found
+* EPICS BASE is distributed subject to a Software License Agreement found
* in file LICENSE that is included with this distribution.
\*************************************************************************/
/* iocsh.cpp */
@@ -68,6 +67,7 @@ struct iocshRedirect {
const char *mode;
FILE *fp;
FILE *oldFp;
+ int mustRestore;
};
/*
@@ -101,7 +101,8 @@ iocshTableUnlock (void)
/*
* Register a command
*/
-void epicsShareAPI iocshRegister (const iocshFuncDef *piocshFuncDef, iocshCallFunc func)
+void epicsShareAPI iocshRegister (const iocshFuncDef *piocshFuncDef,
+ iocshCallFunc func)
{
struct iocshCommand *l, *p, *n;
int i;
@@ -118,7 +119,8 @@ void epicsShareAPI iocshRegister (const iocshFuncDef *piocshFuncDef, iocshCallFu
if (i < 0)
break;
}
- n = (struct iocshCommand *)callocMustSucceed (1, sizeof *n, "iocshRegister");
+ n = (struct iocshCommand *) callocMustSucceed (1, sizeof *n,
+ "iocshRegister");
if (!registryAdd(iocshCmdID, piocshFuncDef->name, (void *)n)) {
free (n);
iocshTableUnlock ();
@@ -162,7 +164,8 @@ void epicsShareAPI iocshRegisterVariable (const iocshVarDef *piocshVarDef)
for (l = NULL, p = iocshVariableHead ; p != NULL ; l = p, p = p->next) {
i = strcmp (piocshVarDef->name, p->pVarDef->name);
if (i == 0) {
- errlogPrintf("Warning -- iocshRegisterVariable redefining %s.\n", piocshVarDef->name);
+ errlogPrintf("Warning: iocshRegisterVariable redefining %s.\n",
+ piocshVarDef->name);
p->pVarDef = piocshVarDef;
found = 1;
break;
@@ -171,11 +174,13 @@ void epicsShareAPI iocshRegisterVariable (const iocshVarDef *piocshVarDef)
break;
}
if (!found) {
- n = (struct iocshVariable *)callocMustSucceed(1, sizeof *n, "iocshRegisterVariable");
+ n = (struct iocshVariable *) callocMustSucceed(1, sizeof *n,
+ "iocshRegisterVariable");
if (!registryAdd(iocshVarID, piocshVarDef->name, (void *)n)) {
free(n);
iocshTableUnlock();
- errlogPrintf("iocshRegisterVariable failed to add %s.\n", piocshVarDef->name);
+ errlogPrintf("iocshRegisterVariable failed to add %s.\n",
+ piocshVarDef->name);
return;
}
if (l == NULL) {
@@ -225,14 +230,15 @@ showError (const char *filename, int lineno, const char *msg, ...)
va_start (ap, msg);
if (filename)
- fprintf (stderr, "%s -- Line %d -- ", filename, lineno);
- vfprintf (stderr, msg, ap);
- fputc ('\n', stderr);
+ fprintf(epicsGetStderr(), "%s line %d: ", filename, lineno);
+ vfprintf (epicsGetStderr(), msg, ap);
+ fputc ('\n', epicsGetStderr());
va_end (ap);
}
static int
-cvtArg (const char *filename, int lineno, char *arg, iocshArgBuf *argBuf, const iocshArg *piocshArg)
+cvtArg (const char *filename, int lineno, char *arg, iocshArgBuf *argBuf,
+ const iocshArg *piocshArg)
{
char *endp;
@@ -245,12 +251,13 @@ cvtArg (const char *filename, int lineno, char *arg, iocshArgBuf *argBuf, const
errno = 0;
argBuf->ival = strtoul (arg, &endp, 0);
if (errno == ERANGE) {
- showError (filename, lineno, "Integer '%s' out of range", arg);
+ showError(filename, lineno, "Integer '%s' out of range",
+ arg);
return 0;
}
}
if (*endp) {
- showError (filename, lineno, "Illegal integer '%s'", arg);
+ showError(filename, lineno, "Illegal integer '%s'", arg);
return 0;
}
}
@@ -263,7 +270,7 @@ cvtArg (const char *filename, int lineno, char *arg, iocshArgBuf *argBuf, const
if (arg && *arg) {
argBuf->dval = epicsStrtod (arg, &endp);
if (*endp) {
- showError (filename, lineno, "Illegal double '%s'", arg);
+ showError(filename, lineno, "Illegal double '%s'", arg);
return 0;
}
}
@@ -279,7 +286,7 @@ cvtArg (const char *filename, int lineno, char *arg, iocshArgBuf *argBuf, const
case iocshArgPersistentString:
argBuf->sval = epicsStrDup(arg);
if (argBuf->sval == NULL) {
- showError (filename, lineno, "Out of memory");
+ showError(filename, lineno, "Out of memory");
return 0;
}
break;
@@ -288,17 +295,18 @@ cvtArg (const char *filename, int lineno, char *arg, iocshArgBuf *argBuf, const
/* Argument must be missing or 0 or pdbbase */
if(!arg || !*arg || (*arg == '0') || (strcmp(arg, "pdbbase") == 0)) {
if(!iocshPpdbbase || !*iocshPpdbbase) {
- showError (filename, lineno, "pdbbase not present");
+ showError(filename, lineno, "pdbbase not present");
return 0;
}
argBuf->vval = *iocshPpdbbase;
break;
}
- showError (filename, lineno, "Expecting 'pdbbase' got '%s'", arg);
+ showError(filename, lineno, "Expecting 'pdbbase' got '%s'", arg);
return 0;
default:
- showError (filename, lineno, "Illegal argument type %d", piocshArg->type);
+ showError(filename, lineno, "Illegal argument type %d",
+ piocshArg->type);
return 0;
}
return 1;
@@ -329,6 +337,7 @@ openRedirect(const char *filename, int lineno, struct iocshRedirect *redirect)
}
return -1;
}
+ redirect->mustRestore = 0;
}
}
return 0;
@@ -349,14 +358,17 @@ startRedirect(const char * /*filename*/, int /*lineno*/,
case 0:
redirect->oldFp = epicsGetThreadStdin();
epicsSetThreadStdin(redirect->fp);
+ redirect->mustRestore = 1;
break;
case 1:
redirect->oldFp = epicsGetThreadStdout();
epicsSetThreadStdout(redirect->fp);
+ redirect->mustRestore = 1;
break;
case 2:
redirect->oldFp = epicsGetThreadStderr();
epicsSetThreadStderr(redirect->fp);
+ redirect->mustRestore = 1;
break;
}
}
@@ -377,10 +389,12 @@ stopRedirect(const char *filename, int lineno, struct iocshRedirect *redirect)
showError(filename, lineno, "Error closing \"%s\": %s.",
redirect->name, strerror(errno));
redirect->fp = NULL;
- switch(i) {
- case 0: epicsSetThreadStdin(redirect->oldFp); break;
- case 1: epicsSetThreadStdout(redirect->oldFp); break;
- case 2: epicsSetThreadStderr(redirect->oldFp); break;
+ if (redirect->mustRestore) {
+ switch(i) {
+ case 0: epicsSetThreadStdin(redirect->oldFp); break;
+ case 1: epicsSetThreadStdout(redirect->oldFp); break;
+ case 2: epicsSetThreadStderr(redirect->oldFp); break;
+ }
}
}
redirect->name = NULL;
@@ -404,30 +418,31 @@ static void helpCallFunc(const iocshArgBuf *args)
if (argc == 1) {
int l, col = 0;
- printf ("Type 'help command_name' to get more information about a particular command.\n");
+ fprintf(epicsGetStdout(),
+ "Type 'help ' to see the arguments of .\n");
iocshTableLock ();
for (pcmd = iocshCommandHead ; pcmd != NULL ; pcmd = pcmd->next) {
piocshFuncDef = pcmd->pFuncDef;
l = strlen (piocshFuncDef->name);
if ((l + col) >= 79) {
- fputc ('\n', stdout);
+ fputc('\n', epicsGetStdout());
col = 0;
}
- fputs (piocshFuncDef->name, stdout);
+ fputs(piocshFuncDef->name, epicsGetStdout());
col += l;
if (col >= 64) {
- fputc ('\n', stdout);
+ fputc('\n', epicsGetStdout());
col = 0;
}
else {
do {
- fputc (' ', stdout);
+ fputc(' ', epicsGetStdout());
col++;
} while ((col % 16) != 0);
}
}
if (col)
- fputc ('\n', stdout);
+ fputc('\n', epicsGetStdout());
iocshTableUnlock ();
}
else {
@@ -435,18 +450,18 @@ static void helpCallFunc(const iocshArgBuf *args)
for (pcmd = iocshCommandHead ; pcmd != NULL ; pcmd = pcmd->next) {
piocshFuncDef = pcmd->pFuncDef;
if (epicsStrGlobMatch(piocshFuncDef->name, argv[iarg]) != 0) {
- fputs (piocshFuncDef->name, stdout);
+ fputs(piocshFuncDef->name, epicsGetStdout());
for (int a = 0 ; a < piocshFuncDef->nargs ; a++) {
const char *cp = piocshFuncDef->arg[a]->name;
if ((piocshFuncDef->arg[a]->type == iocshArgArgv)
|| (strchr (cp, ' ') == NULL)) {
- fprintf (stdout, " %s", cp);
+ fprintf(epicsGetStdout(), " %s", cp);
}
else {
- fprintf (stdout, " '%s'", cp);
+ fprintf(epicsGetStdout(), " '%s'", cp);
}
}
- fprintf (stdout,"\n");;
+ fprintf(epicsGetStdout(),"\n");;
}
}
}
@@ -478,7 +493,6 @@ iocshBody (const char *pathname, const char *commandLine)
iocshArgBuf *argBuf = NULL;
int argBufCapacity = 0;
struct iocshCommand *found;
- struct iocshFuncDef const *piocshFuncDef;
void *readlineContext = NULL;
int wasOkToBlock;
@@ -493,7 +507,8 @@ iocshBody (const char *pathname, const char *commandLine)
else {
fp = fopen (pathname, "r");
if (fp == NULL) {
- fprintf (stderr, "Can't open %s: %s\n", pathname, strerror (errno));
+ fprintf(epicsGetStderr(), "Can't open %s: %s\n", pathname,
+ strerror (errno));
return -1;
}
if ((filename = strrchr (pathname, '/')) == NULL)
@@ -507,7 +522,7 @@ iocshBody (const char *pathname, const char *commandLine)
* Create a command-line input context
*/
if ((readlineContext = epicsReadlineBegin(fp)) == NULL) {
- fprintf(stderr, "Can't allocate command-line object.\n");
+ fprintf(epicsGetStderr(), "Can't allocate command-line object.\n");
if (fp)
fclose(fp);
return -1;
@@ -519,7 +534,7 @@ iocshBody (const char *pathname, const char *commandLine)
*/
redirects = (struct iocshRedirect *)calloc(NREDIRECTS, sizeof *redirects);
if (redirects == NULL) {
- printf ("Out of memory!\n");
+ fprintf(epicsGetStderr(), "Out of memory!\n");
return -1;
}
@@ -604,7 +619,7 @@ iocshBody (const char *pathname, const char *commandLine)
argvCapacity += 50;
av = (char **)realloc (argv, argvCapacity * sizeof *argv);
if (av == NULL) {
- printf ("Out of memory!\n");
+ fprintf (epicsGetStderr(), "Out of memory!\n");
argc = -1;
break;
}
@@ -699,17 +714,17 @@ iocshBody (const char *pathname, const char *commandLine)
backslash = 0;
}
if (redirect != NULL) {
- showError (filename, lineno, "Illegal redirection.");
+ showError(filename, lineno, "Illegal redirection.");
continue;
}
if (argc < 0)
break;
if (quote != EOF) {
- showError (filename, lineno, "Unbalanced quote.");
+ showError(filename, lineno, "Unbalanced quote.");
continue;
}
if (backslash) {
- showError (filename, lineno, "Trailing backslash.");
+ showError(filename, lineno, "Trailing backslash.");
continue;
}
if (inword)
@@ -730,73 +745,68 @@ iocshBody (const char *pathname, const char *commandLine)
stopRedirect(filename, lineno, redirects);
continue;
}
- if (openRedirect(filename, lineno, redirects) < 0)
- continue;
/*
- * Look up command
+ * Special command?
*/
- if (argc) {
- /*
- * Special command?
- */
- if (strncmp (argv[0], "exit", 4) == 0)
- break;
- if ((strcmp (argv[0], "?") == 0)
- || (strncmp (argv[0], "help", 4) == 0)) {
- }
+ if ((argc > 0) && (strcmp(argv[0], "exit") == 0))
+ break;
+ /*
+ * Set up redirection
+ */
+ if ((openRedirect(filename, lineno, redirects) == 0) && (argc > 0)) {
/*
* Look up command
*/
found = (iocshCommand *)registryFind (iocshCmdID, argv[0]);
- if (!found) {
- showError (filename, lineno, "Command %s not found.", argv[0]);
- continue;
- }
- piocshFuncDef = found->pFuncDef;
-
- /*
- * Process arguments and call function
- */
- for (int iarg = 0 ; ; ) {
- if (iarg == piocshFuncDef->nargs) {
- startRedirect(filename, lineno, redirects);
- (*found->func)(argBuf);
- stopRedirect(filename, lineno, redirects);
- break;
- }
- if (iarg >= argBufCapacity) {
- void *np;
-
- argBufCapacity += 20;
- np = realloc (argBuf, argBufCapacity * sizeof *argBuf);
- if (np == NULL) {
- fprintf (stderr, "Out of memory!\n");
- argBufCapacity -= 20;
+ if (found) {
+ /*
+ * Process arguments and call function
+ */
+ struct iocshFuncDef const *piocshFuncDef = found->pFuncDef;
+ for (int iarg = 0 ; ; ) {
+ if (iarg == piocshFuncDef->nargs) {
+ startRedirect(filename, lineno, redirects);
+ (*found->func)(argBuf);
break;
}
- argBuf = (iocshArgBuf *)np;
+ if (iarg >= argBufCapacity) {
+ void *np;
+
+ argBufCapacity += 20;
+ np = realloc (argBuf, argBufCapacity * sizeof *argBuf);
+ if (np == NULL) {
+ fprintf (epicsGetStderr(), "Out of memory!\n");
+ argBufCapacity -= 20;
+ break;
+ }
+ argBuf = (iocshArgBuf *)np;
+ }
+ if (piocshFuncDef->arg[iarg]->type == iocshArgArgv) {
+ argBuf[iarg].aval.ac = argc-iarg;
+ argBuf[iarg].aval.av = argv+iarg;
+ iarg = piocshFuncDef->nargs;
+ }
+ else {
+ if (!cvtArg (filename, lineno,
+ ((iarg < argc) ? argv[iarg+1] : NULL),
+ &argBuf[iarg], piocshFuncDef->arg[iarg]))
+ break;
+ iarg++;
+ }
}
- if (piocshFuncDef->arg[iarg]->type == iocshArgArgv) {
- argBuf[iarg].aval.ac = argc-iarg;
- argBuf[iarg].aval.av = argv+iarg;
- iarg = piocshFuncDef->nargs;
- }
- else {
- if (!cvtArg (filename, lineno,
- ((iarg < argc) ? argv[iarg+1] : NULL),
- &argBuf[iarg], piocshFuncDef->arg[iarg]))
- break;
- iarg++;
+ if ((prompt != NULL) && (strcmp(argv[0], "epicsEnvSet") == 0)) {
+ const char *newPrompt;
+ if ((newPrompt = envGetConfigParamPtr(&IOCSH_PS1)) != NULL)
+ prompt = newPrompt;
}
}
- if((prompt != NULL) && (strcmp(argv[0], "epicsEnvSet") == 0)) {
- const char *newPrompt;
- if ((newPrompt = envGetConfigParamPtr(&IOCSH_PS1)) != NULL)
- prompt = newPrompt;
+ else {
+ showError(filename, lineno, "Command %s not found.", argv[0]);
}
}
+ stopRedirect(filename, lineno, redirects);
}
if (fp && (fp != stdin))
fclose (fp);
@@ -840,7 +850,8 @@ static void varHandler(const iocshVarDef *v, const char *setString)
{
switch(v->type) {
default:
- printf("Can't handle variable %s of type %d.\n", v->name, v->type);
+ fprintf(epicsGetStderr(), "Can't handle variable %s of type %d.\n",
+ v->name, v->type);
return;
case iocshArgInt: break;
case iocshArgDouble: break;
@@ -849,10 +860,10 @@ static void varHandler(const iocshVarDef *v, const char *setString)
switch(v->type) {
default: break;
case iocshArgInt:
- printf("%s = %d\n", v->name, *(int *)v->pval);
+ fprintf(epicsGetStdout(), "%s = %d\n", v->name, *(int *)v->pval);
break;
case iocshArgDouble:
- printf("%s = %g\n", v->name, *(double *)v->pval);
+ fprintf(epicsGetStdout(), "%s = %g\n", v->name, *(double *)v->pval);
break;
}
}
@@ -866,7 +877,8 @@ static void varHandler(const iocshVarDef *v, const char *setString)
if((*setString != '\0') && (*endp == '\0'))
*(int *)v->pval = ltmp;
else
- printf("Invalid value -- value of %s not changed.\n", v->name);
+ fprintf(epicsGetStderr(),
+ "Invalid integer value. Var %s not changed.\n", v->name);
break;
}
case iocshArgDouble:
@@ -876,7 +888,8 @@ static void varHandler(const iocshVarDef *v, const char *setString)
if((*setString != '\0') && (*endp == '\0'))
*(double *)v->pval = dtmp;
else
- printf("Invalid value -- value of %s not changed.\n", v->name);
+ fprintf(epicsGetStderr(),
+ "Invalid double value. Var %s not changed.\n", v->name);
break;
}
}
@@ -893,7 +906,7 @@ static void varCallFunc(const iocshArgBuf *args)
else {
v = (iocshVariable *)registryFind(iocshVarID, args[0].sval);
if (v == NULL) {
- printf("%s -- no such variable.\n", args[0].sval);
+ fprintf(epicsGetStderr(), "Var %s not found.\n", args[0].sval);
}
else {
varHandler(v->pVarDef, args[1].sval);
@@ -916,7 +929,8 @@ static void iocshCmdCallFunc(const iocshArgBuf *args)
*/
/* comment */
-static const iocshArg commentArg0 = { "newline-terminated comment",iocshArgArgv};
+static const iocshArg commentArg0 = { "newline-terminated comment",
+ iocshArgArgv};
static const iocshArg *commentArgs[1] = {&commentArg0};
static const iocshFuncDef commentFuncDef = {"#",1,commentArgs};
static void commentCallFunc(const iocshArgBuf *)
diff --git a/src/libCom/iocsh/libComRegister.c b/src/libCom/iocsh/libComRegister.c
index 6cd79bb66..4be706dc7 100644
--- a/src/libCom/iocsh/libComRegister.c
+++ b/src/libCom/iocsh/libComRegister.c
@@ -9,10 +9,10 @@
\*************************************************************************/
#include
-#include
#define epicsExportSharedSymbols
#include "iocsh.h"
+#include "epicsStdioRedirect.h"
#include "epicsTime.h"
#include "epicsThread.h"
#include "epicsMutex.h"
@@ -60,7 +60,7 @@ static void chdirCallFunc(const iocshArgBuf *args)
int status;
status = chdir(args[0].sval);
if (status) {
- printf ("Invalid directory path ignored\n");
+ fprintf(stderr, "Invalid directory path, ignored\n");
}
}
@@ -86,11 +86,11 @@ static void epicsEnvSetCallFunc(const iocshArgBuf *args)
char *value = args[1].sval;
if (name == NULL) {
- printf ("Missing environment variable name argument.\n");
+ fprintf(stderr, "Missing environment variable name argument.\n");
return;
}
if (value == NULL) {
- printf ("Missing environment variable value argument.\n");
+ fprintf(stderr, "Missing environment variable value argument.\n");
return;
}
epicsEnvSet (name, value);
@@ -231,7 +231,7 @@ static void threadCallFunc(const iocshArgBuf *args)
if (*endp) {
tid = epicsThreadGetId (cp);
if (!tid) {
- printf ("\t'%s' is not a known thread name\n", cp);
+ fprintf(stderr, "\t'%s' is not a known thread name\n", cp);
continue;
}
}
@@ -299,7 +299,7 @@ static void epicsThreadResumeCallFunc(const iocshArgBuf *args)
if (*endp) {
tid = epicsThreadGetId(cp);
if (!tid) {
- printf("*** argument %d (%s) is not a valid thread name ***\n", i, cp);
+ fprintf(stderr, "'%s' is not a valid thread name\n", cp);
continue;
}
}
@@ -307,13 +307,13 @@ static void epicsThreadResumeCallFunc(const iocshArgBuf *args)
tid =(epicsThreadId)ltmp;
epicsThreadGetName(tid, nameBuf, sizeof nameBuf);
if (nameBuf[0] == '\0') {
- printf("*** argument %d (%s) is not a valid thread id ***\n", i, cp);
+ fprintf(stderr, "'%s' is not a valid thread id\n", cp);
continue;
}
}
if (!epicsThreadIsSuspended(tid)) {
- printf("*** Thread %s is not suspended ***\n", cp);
+ fprintf(stderr, "Thread %s is not suspended\n", cp);
continue;
}
epicsThreadResume(tid);
diff --git a/src/libCom/osi/epicsGeneralTime.c b/src/libCom/osi/epicsGeneralTime.c
index 819220ea7..8ef8a73cc 100644
--- a/src/libCom/osi/epicsGeneralTime.c
+++ b/src/libCom/osi/epicsGeneralTime.c
@@ -9,7 +9,6 @@
/* Original Authors: David H. Thompson & Sheng Peng (ORNL) */
-#include
#include
#include
@@ -19,6 +18,7 @@
#include "epicsMutex.h"
#include "epicsMessageQueue.h"
#include "epicsString.h"
+#include "epicsStdioRedirect.h"
#include "epicsThread.h"
#include "epicsTime.h"
#include "epicsTimer.h"
diff --git a/src/libCom/taskwd/taskwd.c b/src/libCom/taskwd/taskwd.c
index c034e1828..f8a061c2c 100644
--- a/src/libCom/taskwd/taskwd.c
+++ b/src/libCom/taskwd/taskwd.c
@@ -22,7 +22,7 @@
#include "dbDefs.h"
#include "epicsEvent.h"
#include "epicsExit.h"
-#include "epicsStdio.h"
+#include "epicsStdioRedirect.h"
#include "epicsThread.h"
#include "epicsMutex.h"
#include "errlog.h"