do not ignore the return value of system(cmd) anymore.

This commit is contained in:
suter_a 2022-04-11 16:10:00 +02:00
parent 9cc1957b2d
commit 17a31dfcc4
6 changed files with 45 additions and 11 deletions

View File

@ -1308,7 +1308,9 @@ bool PMsr2Data::PrepareGlobalInputFile(unsigned int tempRun, const std::string &
std::ostringstream oss; std::ostringstream oss;
oss << path << "musrfit" << " " << *fRunVectorIter << "-OneRunFit" << fFileExtension << ".msr"; oss << path << "musrfit" << " " << *fRunVectorIter << "-OneRunFit" << fFileExtension << ".msr";
std::cout << std::endl << ">> msr2data: **INFO** Calling " << oss.str() << std::endl; std::cout << std::endl << ">> msr2data: **INFO** Calling " << oss.str() << std::endl;
system(oss.str().c_str()); if (system(oss.str().c_str()) == -1) {
std::cerr << std::endl << "**ERROR** system call: " << oss.str().c_str() << " failed." << std::endl;
}
++fRunVectorIter; ++fRunVectorIter;
} }

View File

@ -724,7 +724,9 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
sprintf(cmd, "tar -zcf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[0].Data()); sprintf(cmd, "tar -zcf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[0].Data());
else // bzip2 else // bzip2
sprintf(cmd, "tar -jcf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[0].Data()); sprintf(cmd, "tar -jcf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[0].Data());
system(cmd); if (system(cmd) == -1) {
std::cerr << "**ERROR** cmd: " << cmd << " failed." << std::endl;
}
} else { } else {
fln += TString(".tar"); fln += TString(".tar");
for (UInt_t i=0; i<fAny2ManyInfo->outPathFileName.size(); i++) { for (UInt_t i=0; i<fAny2ManyInfo->outPathFileName.size(); i++) {
@ -733,7 +735,9 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
} else { } else {
sprintf(cmd, "tar -rf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[i].Data()); sprintf(cmd, "tar -rf %s %s", fln.Data(), fAny2ManyInfo->outPathFileName[i].Data());
} }
system(cmd); if (system(cmd) == -1) {
std::cerr << "**ERROR** cmd: " << cmd << " failed." << std::endl;
}
} }
if (fAny2ManyInfo->compressionTag == 1) { // gzip if (fAny2ManyInfo->compressionTag == 1) { // gzip
sprintf(cmd, "gzip %s", fln.Data()); sprintf(cmd, "gzip %s", fln.Data());
@ -742,7 +746,9 @@ Bool_t PRunDataHandler::ReadWriteFilesList()
sprintf(cmd, "bzip2 -z %s", fln.Data()); sprintf(cmd, "bzip2 -z %s", fln.Data());
fln += ".bz2"; fln += ".bz2";
} }
system(cmd); if (system(cmd) == -1) {
std::cerr << "**ERROR** cmd: " << cmd << " failed." << std::endl;
}
} }
// check if the compressed file shall be streamed to the stdout // check if the compressed file shall be streamed to the stdout

View File

@ -893,7 +893,9 @@ int main(int argc, char *argv[])
std::ostringstream oss; std::ostringstream oss;
oss << path << "musrfit" << " " << strInfile.str() << " " << musrfitOptions; oss << path << "musrfit" << " " << strInfile.str() << " " << musrfitOptions;
std::cout << std::endl << ">> msr2data: **INFO** Calling " << oss.str() << std::endl; std::cout << std::endl << ">> msr2data: **INFO** Calling " << oss.str() << std::endl;
system(oss.str().c_str()); if (system(oss.str().c_str()) == -1) {
std::cerr << "**ERROR** cmd: " << oss.str().c_str() << " failed." << std::endl;
}
} }
} }
@ -982,7 +984,9 @@ int main(int argc, char *argv[])
std::ostringstream oss; std::ostringstream oss;
oss << path << "musrfit" << " " << strInfile.str() << " " << musrfitOptions; oss << path << "musrfit" << " " << strInfile.str() << " " << musrfitOptions;
std::cout << std::endl << ">> msr2data: **INFO** Calling " << oss.str() << std::endl; std::cout << std::endl << ">> msr2data: **INFO** Calling " << oss.str() << std::endl;
system(oss.str().c_str()); if (system(oss.str().c_str()) == -1) {
std::cerr << "**ERROR** cmd: " << oss.str().c_str() << " failed." << std::endl;
}
} }
} }

View File

@ -574,10 +574,16 @@ bool msr2msr_finalize_theory(char *fln, int theoryTag, int noOfAddionalParams)
// cp __temp.msr fln // cp __temp.msr fln
sprintf(str, "cp __temp.msr %s", fln); sprintf(str, "cp __temp.msr %s", fln);
system(str); if (system(str) == -1) {
std::cerr << "**ERROR** cmd: " << str << " failed." << std::endl;
return false;
}
// rm __temp.msr // rm __temp.msr
strcpy(str, "rm __temp.msr"); strcpy(str, "rm __temp.msr");
system(str); if (system(str) == -1) {
std::cerr << "**ERROR** cmd: " << str << " failed." << std::endl;
return false;
}
return true; return true;
} }
@ -704,7 +710,10 @@ int main(int argc, char *argv[])
// check if conversion seems to be OK // check if conversion seems to be OK
if (!success) { if (!success) {
sprintf(str, "rm -rf %s", argv[2]); sprintf(str, "rm -rf %s", argv[2]);
system(str); if (system(str) == -1) {
std::cerr << "**ERROR** cmd: " << str << " failed." << std::endl;
return 0;
}
} }
if (theoryTag != -1) { if (theoryTag != -1) {

View File

@ -123,7 +123,14 @@ PDumpOutputHandler::~PDumpOutputHandler()
#else #else
qDebug() << msg << Qt::endl; qDebug() << msg << Qt::endl;
#endif #endif
system(cmd.toLatin1()); if (system(cmd.toLatin1()) == -1) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
qDebug() << "**ERROR** " << msg << " failed." << endl;
#else
qDebug() << "**ERROR** " << msg << " failed." << Qt::endl;
#endif
}
} }
if (fProc) { if (fProc) {
delete fProc; delete fProc;

View File

@ -126,7 +126,13 @@ PFitOutputHandler::~PFitOutputHandler()
#else #else
qDebug() << msg << Qt::endl; qDebug() << msg << Qt::endl;
#endif #endif
system(cmd.toLatin1()); if (system(cmd.toLatin1()) == -1) {
#if (QT_VERSION < QT_VERSION_CHECK(5, 14, 0))
qDebug() << "**ERROR** " << msg << " - failed!" << endl;
#else
qDebug() << "**ERROR** " << msg << " - failed!" << Qt::endl;
#endif
}
} }
if (fProc) { if (fProc) {
delete fProc; delete fProc;