diff --git a/src/rt/RcontribSimulManager.cpp b/src/rt/RcontribSimulManager.cpp index 5a85f645..a361a464 100644 --- a/src/rt/RcontribSimulManager.cpp +++ b/src/rt/RcontribSimulManager.cpp @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: RcontribSimulManager.cpp,v 2.2 2024/10/29 19:47:19 greg Exp $"; +static const char RCSid[] = "$Id: RcontribSimulManager.cpp,v 2.3 2024/10/30 01:38:21 greg Exp $"; #endif /* * RcontribSimulManager.cpp @@ -443,7 +443,8 @@ RcontribOutput::CheckHeader(const RcontribSimulManager *rcp) return -1; } // check format - if (!(cp = findArgs(hdr, FMTSTR, begData)) || strcmp(cp, formstr(etyp))) { + if (!(cp = findArgs(hdr, FMTSTR, begData)) || + strncmp(cp, formstr(etyp), strlen(formstr(etyp)))) { sprintf(errmsg, "expected %s%s in '%s'", FMTSTR, formstr(etyp), GetName()); error(USER, errmsg); return -1; @@ -632,7 +633,8 @@ RcontribSimulManager::GetChild(bool forceWait) FD_ISSET(kid[n].w, &writeset) | FD_ISSET(kid[n].w, &errset)) { // update output row counts - UpdateRowsDone(kidRow[n]); + if (!FD_ISSET(kid[n].w, &errset)) + UpdateRowsDone(kidRow[n]); kidRow[n] = -1; // flag it available pn = n; } @@ -716,7 +718,6 @@ RcontribSimulManager::StartKids(int n2go) close(kid[nkids].w); free(kid); free(kidRow); kid = NULL; kidRow = NULL; - rowsDone.NewBitMap(0); RunChild(); // should never return _exit(1); } diff --git a/src/rt/RcontribSimulManager.h b/src/rt/RcontribSimulManager.h index cd3d705e..9c030807 100644 --- a/src/rt/RcontribSimulManager.h +++ b/src/rt/RcontribSimulManager.h @@ -1,4 +1,4 @@ -/* RCSid $Id: RcontribSimulManager.h,v 2.2 2024/10/29 19:47:19 greg Exp $ */ +/* RCSid $Id: RcontribSimulManager.h,v 2.3 2024/10/30 01:38:21 greg Exp $ */ /* * RcontribSimulManager.h * @@ -154,7 +154,7 @@ extern lut_free_t FreeRcMod; */ /// Output channel opening options: new/exclusive, overwrite if exists, or recover data -enum RCOutputOp {RCOnew, RCOforce, RCOrecover}; +enum RCOutputOp {RCOnew=0, RCOforce, RCOrecover}; /// Converts above to RdataShare open flags (may be adjusted by calling program) extern int RSDOflags[]; diff --git a/src/rt/RdataShareFile.cpp b/src/rt/RdataShareFile.cpp index a5294e67..4ace3bd1 100644 --- a/src/rt/RdataShareFile.cpp +++ b/src/rt/RdataShareFile.cpp @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: RdataShareFile.cpp,v 2.1 2024/10/29 00:36:54 greg Exp $"; +static const char RCSid[] = "$Id: RdataShareFile.cpp,v 2.2 2024/10/30 01:38:21 greg Exp $"; #endif /* * RdataShareFile.cpp @@ -84,16 +84,16 @@ RdataShareFile::RdataShareFile(const char *name, int flags, size_t siz) int oflags = O_CLOEXEC; switch (flags & (RDSread|RDSwrite)) { case RDSread|RDSwrite: - oflags |= O_RDWR; + oflags |= O_RDWR|O_CREAT; + break; + case RDSwrite: + oflags |= O_WRONLY|O_CREAT; break; case RDSread: oflags |= O_RDONLY; break; - case RDSwrite: - oflags |= O_WRONLY; - break; } - if (flags & RDSexcl) oflags |= O_CREAT|O_EXCL; + if (flags & RDSexcl) oflags |= O_EXCL; else if (flags & RDSextend && !siz) oflags |= O_TRUNC; fd = open(name, oflags, 0666); if (fd < 0) { diff --git a/src/rt/RdataShareMap.cpp b/src/rt/RdataShareMap.cpp index d13d5414..d120aaf4 100644 --- a/src/rt/RdataShareMap.cpp +++ b/src/rt/RdataShareMap.cpp @@ -1,5 +1,5 @@ #ifndef lint -static const char RCSid[] = "$Id: RdataShareMap.cpp,v 2.1 2024/10/29 00:36:54 greg Exp $"; +static const char RCSid[] = "$Id: RdataShareMap.cpp,v 2.2 2024/10/30 01:38:21 greg Exp $"; #endif /* * RdataShareMap.cpp @@ -36,25 +36,24 @@ RdataShareMap::RdataShareMap(const char *name, int flags, size_t siz) error(CONSISTENCY, "bad RDSextend in RdataShareMap()"); return; } - int mmprot = PROT_NONE; - int oflags = 0; + int oflags, mmprot; switch (flags & (RDSread|RDSwrite)) { case RDSread|RDSwrite: - mmprot |= PROT_READ|PROT_WRITE; - oflags |= O_RDWR; - break; - case RDSread: - mmprot |= PROT_READ; - oflags |= O_RDONLY; + mmprot = PROT_READ|PROT_WRITE; + oflags = O_RDWR|O_CREAT; break; case RDSwrite: - mmprot |= PROT_WRITE; - oflags |= O_WRONLY; + mmprot = PROT_WRITE; + oflags = O_RDWR|O_CREAT; // XXX system limitation + break; + case RDSread: + mmprot = PROT_READ; + oflags = O_RDONLY; break; } int fd = -1; if (name) { // opening a shared file - if (flags & RDSexcl) oflags |= O_CREAT|O_EXCL; + if (flags & RDSexcl) oflags |= O_EXCL; else if (flags & RDSextend && !siz) oflags |= O_TRUNC; fd = open(name, oflags, 0666); if (fd < 0) {