diff --git a/run/O2HitMerger.h b/run/O2HitMerger.h index c2a094bfc9e54..520873e7aaafe 100644 --- a/run/O2HitMerger.h +++ b/run/O2HitMerger.h @@ -87,15 +87,6 @@ namespace o2 namespace devices { -// signal handler -void sighandler(int signal) -{ - if (signal == SIGSEGV) { - LOG(warn) << "segmentation violation ... just exit without coredump in order not to hang"; - raise(SIGKILL); - } -} - class O2HitMerger : public fair::mq::Device { @@ -130,7 +121,6 @@ class O2HitMerger : public fair::mq::Device void InitTask() final { LOG(info) << "INIT HIT MERGER"; - // signal(SIGSEGV, sighandler); ROOT::EnableThreadSafety(); std::string outfilename("o2sim_merged_hits.root"); // default name @@ -764,7 +754,6 @@ class O2HitMerger : public fair::mq::Device eventheader->putInfo("prims_eta_0.8_pi", eta0Point8CounterPi); eventheader->putInfo("prims_total", prims); }; - reorderAndMergeMCTracks(flusheventID, mOutTree, nprimaries, subevOrdered, mcheaderhook, eventheader); if (mOutTree) { diff --git a/run/o2sim_parallel.cxx b/run/o2sim_parallel.cxx index 3e28428938b20..0dabafaf40c67 100644 --- a/run/o2sim_parallel.cxx +++ b/run/o2sim_parallel.cxx @@ -732,7 +732,12 @@ int main(int argc, char* argv[]) int status, cpid; // wait just blocks and waits until any child returns; but we make sure to wait until merger is here bool errored = false; - while ((cpid = wait(&status)) != mergerpid) { + // wait at least until mergerpid is reaped + while ((cpid = wait(&status)) != -1) { + if (cpid == mergerpid) { + break; // Defer handling of mergerpid exit status until after the loop + } + if (WEXITSTATUS(status) || WIFSIGNALED(status)) { if (!shutdown_initiated) { LOG(info) << "Process " << cpid << " EXITED WITH CODE " << WEXITSTATUS(status) << " SIGNALED " @@ -753,6 +758,25 @@ int main(int argc, char* argv[]) } } } + // Handle mergerpid status separately + if (cpid == mergerpid) { + if (WIFEXITED(status)) { + // anything other than 128 is indicative of error + if (WEXITSTATUS(status) != 128) { + LOG(error) << "Merger process exited with abnormal code " << WEXITSTATUS(status); + errored = true; + } + } else if (WIFSIGNALED(status)) { + auto sig = WTERMSIG(status); + if (sig == SIGKILL || sig == SIGBUS || sig == SIGSEGV || sig == SIGABRT) { + LOG(error) << "Merger process terminated through abnormal signal " << WTERMSIG(status); + errored = true; + } + } else { + LOG(warning) << "Merger process exited with unexpected status."; + } + } + // This marks the actual end of the computation (since results are available) LOG(info) << "Merger process " << mergerpid << " returned"; LOG(info) << "Simulation process took " << timer.RealTime() << " s";