From f2e9e6b39f04ade74bd0f07431b3c43dc21092ca Mon Sep 17 00:00:00 2001 From: Andrea Marini Date: Thu, 26 Sep 2024 11:08:36 +0200 Subject: [PATCH] Silencing ZZ warnings (#1007) * silencing ZZ complains * silencing ZZ complains on Asimov * trying to dup the file descriptors. this should work on condor and on local. * fixing freopen --- src/CachingNLL.cc | 11 +++++++---- src/ToyMCSamplerOpt.cc | 13 ++++++++----- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/CachingNLL.cc b/src/CachingNLL.cc index 04e91c4eca4..ae00bc27e6a 100644 --- a/src/CachingNLL.cc +++ b/src/CachingNLL.cc @@ -611,6 +611,8 @@ cacheutils::CachingAddNLL::setIncludeZeroWeights(bool includeZeroWeights) } } +int orig2_stdout_fd = fileno(stdout); + Double_t cacheutils::CachingAddNLL::evaluate() const { @@ -638,12 +640,13 @@ cacheutils::CachingAddNLL::evaluate() const } // get vals //std::cout<<"Silence is gold!"< &pdfvals = itp->eval(*data_); - //freopen("/dev/tty", "w", stdout); - dup2(stdout_fd, STDOUT_FILENO); - stdout = fdopen(stdout_fd, "w"); + + close(fileno(stdout)); + dup2(stdout_fd, orig2_stdout_fd); + stdout = fdopen(orig2_stdout_fd, "w"); close(stdout_fd); //std::cout<<"I am alive!"<createHistogram("htemp", *x, ay, az); @@ -267,10 +269,11 @@ toymcoptutils::SinglePdfGenInfo::generateWithHisto(RooRealVar *&weightVar, bool if (!keepHistoSpec_) { delete histoSpec_; histoSpec_ = 0; } //std::cout << "Asimov dataset generated from " << pdf_->GetName() << " (sumw? " << data->sumEntries() << ", expected events " << expectedEvents << ")" << std::endl; //utils::printRDH(data); - //freopen("/dev/tty", "w", stdout); - dup2(stdout_fd, STDOUT_FILENO); - stdout = fdopen(stdout_fd, "w"); - close(stdout_fd); + //assert(orig_stdout_fd == fileno(stdout)); + close(fileno(stdout));//de-associate dev/null from 1 + dup2(stdout_fd, orig_stdout_fd);//re-associate stdout to 1 + stdout = fdopen(orig_stdout_fd, "w"); + close(stdout_fd); //de-associate the stdout_fd from stream return data; }