summaryrefslogtreecommitdiffstats
path: root/tools/ompipe.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/ompipe.c')
-rw-r--r--tools/ompipe.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/tools/ompipe.c b/tools/ompipe.c
index e3d11805..cbedb559 100644
--- a/tools/ompipe.c
+++ b/tools/ompipe.c
@@ -38,6 +38,7 @@
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
+#include <unistd.h>
#include <assert.h>
#include <errno.h>
#include <fcntl.h>
@@ -56,6 +57,7 @@
#include "errmsg.h"
MODULE_TYPE_OUTPUT
+MODULE_TYPE_NOKEEP
/* internal structures
*/
@@ -70,6 +72,7 @@ DEFobjCurrIf(errmsg)
typedef struct _instanceData {
uchar f_fname[MAXFNAME];/* pipe or template name (display only) */
short fd; /* pipe descriptor for (current) pipe */
+ sbool bHadError; /* did we already have/report an error on this pipe? */
} instanceData;
@@ -99,6 +102,17 @@ preparePipe(instanceData *pData)
{
DEFiRet;
pData->fd = open((char*) pData->f_fname, O_RDWR|O_NONBLOCK|O_CLOEXEC);
+ if(pData->fd < 0 ) {
+ pData->fd = -1;
+ if(!pData->bHadError) {
+ char errStr[1024];
+ rs_strerror_r(errno, errStr, sizeof(errStr));
+ errmsg.LogError(0, RS_RET_NO_FILE_ACCESS, "Could no open output pipe '%s': %s",
+ pData->f_fname, errStr);
+ pData->bHadError = 1;
+ }
+ DBGPRINTF("Error opening log pipe: %s\n", pData->f_fname);
+ }
RETiRet;
}
@@ -148,6 +162,7 @@ finalize_it:
BEGINcreateInstance
CODESTARTcreateInstance
pData->fd = -1;
+ pData->bHadError = 0;
ENDcreateInstance
@@ -202,11 +217,6 @@ CODESTARTparseSelectorAct
*/
preparePipe(pData);
- if(pData->fd < 0 ) {
- pData->fd = -1;
- DBGPRINTF("Error opening log pipe: %s\n", pData->f_fname);
- errmsg.LogError(0, RS_RET_NO_FILE_ACCESS, "Could no open output pipe '%s'", pData->f_fname);
- }
CODE_STD_FINALIZERparseSelectorAct
ENDparseSelectorAct