Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 0 additions & 11 deletions run/O2HitMerger.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
{

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down
26 changes: 25 additions & 1 deletion run/o2sim_parallel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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 "
Expand All @@ -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";
Expand Down