Skip to content
Merged
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
22 changes: 18 additions & 4 deletions run/o2sim_parallel.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,9 @@ void launchShutdownThread()
}
LOG(info) << "Shutdown timer expired ... force killing remaining children";
for (auto p : gChildProcesses) {
killpg(p, SIGKILL);
if (p != 0 && killpg(p, 0) == 0) { // see if process still exists
killpg(p, SIGKILL);
}
}
};
threads.push_back(std::thread(lambda));
Expand Down Expand Up @@ -440,6 +442,12 @@ int main(int argc, char* argv[])
// we enable the forked version of the code by default
setenv("ALICE_SIMFORKINTERNAL", "ON", 1);

// force execution as own process group
if (setpgid(0, 0) == -1) {
perror("setpgid");
exit(1);
}

TStopwatch timer;
timer.Start();
auto o2env = getenv("O2_ROOT");
Expand Down Expand Up @@ -703,7 +711,9 @@ int main(int argc, char* argv[])
if (!shutdown_initiated) {
shutdown_initiated = true;
for (auto p : gChildProcesses) {
killpg(p, SIGTERM);
if (killpg(p, 0) == 0) {
killpg(p, SIGTERM);
}
}
}
} else {
Expand Down Expand Up @@ -733,7 +743,9 @@ int main(int argc, char* argv[])
LOG(info) << "Problem detected (or child received termination signal) ... shutting down whole system ";
for (auto p : gChildProcesses) {
LOG(info) << "TERMINATING " << p;
killpg(p, SIGTERM); // <--- makes sure to shutdown "unknown" child pids via the group property
if (killpg(p, 0) == 0) {
killpg(p, SIGTERM); // <--- makes sure to shutdown "unknown" child pids via the group property
}
}
LOG(error) << "SHUTTING DOWN DUE TO SIGNALED EXIT IN COMPONENT " << cpid;
o2::simpubsub::publishMessage(externalpublishchannel, o2::simpubsub::simStatusString("O2SIM", "STATE", "FAILURE"));
Expand All @@ -751,7 +763,9 @@ int main(int argc, char* argv[])
for (auto p : gChildProcesses) {
if (p != mergerpid) {
LOG(info) << "SHUTTING DOWN CHILD PROCESS (normal thread)" << p;
killpg(p, SIGTERM);
if (killpg(p, 0) == 0) {
killpg(p, SIGTERM);
}
}
}
}
Expand Down