Skip to content
Draft
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@


### Changed (changing behavior/API/variables/...)
- [[PR 782]](https://github.com/parthenon-hpc-lab/parthenon/pull/782) Die on repeatedly receiving SIGINT

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [[PR 782]](https://github.com/parthenon-hpc-lab/parthenon/pull/782) Die on repeatedly receiving SIGINT
- [[PR 1446]](https://github.com/parthenon-hpc-lab/parthenon/pull/1446) Die on repeatedly receiving SIGINT

- [[PR 1438]](https://github.com/parthenon-hpc-lab/parthenon/pull/1438) Performance tuning for the loop abstraction machinery and add loop abstraction OpenMP support
- [[PR 1416][(https://github.com/parthenon-hpc-lab/parthenon/pull/1416) Remove virtual tag from destructors in sparse and swarm pack base classes
- [[PR 1401]](https://github.com/parthenon-hpc-lab/parthenon/pull/1401) Sparse Field Component Names
Expand Down
9 changes: 6 additions & 3 deletions src/utils/signal_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

// first 2x macros and signal() are the only ISO C features; rest are POSIX C extensions
#include <csignal>
#include <filesystem>
#include <iostream>

#include FS_HEADER
Expand Down Expand Up @@ -132,15 +133,17 @@ void SetSignalFlag(int s) {
// Signal handler functions must have C linkage; C++ linkage is implemantation-defined
switch (s) {
case SIGTERM:
signalflag[ITERM] = 1;
signalflag[ITERM] += 1;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you also plan to use the counter here or why is the "+"=1 important?

signal(s, SetSignalFlag);
break;
case SIGINT:
signalflag[IINT] = 1;
signalflag[IINT] += 1;
if (signalflag[IINT] >= SIGINTS_BEFORE_THROW)
PARTHENON_THROW("Terminating immediately on repeated Terminate signal");
signal(s, SetSignalFlag);
break;
case SIGALRM:
signalflag[IALRM] = 1;
signalflag[IALRM] += 1;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here.

signal(s, SetSignalFlag);
break;
default:
Expand Down
11 changes: 9 additions & 2 deletions src/utils/utils.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,18 @@ void WatchDog(int timeout);
// \brief static data and functions that implement a simple signal handling system
namespace SignalHandler {

// Enum of desired signal results
enum class OutputSignal { none, now, final, analysis };
// Signals handled: SIGTERM, SIGINT, SIGALRM
constexpr int ITERM = 0, IINT = 1, IALRM = 2;
constexpr int nsignal = 3;
// using the +1 for signaling based on "output_now" trigger
// Flag/counter of signals received of each type
// using the +1 for signaling based on a trigger file
static volatile int signalflag[nsignal + 1];
const int ITERM = 0, IINT = 1, IALRM = 2;

// Immediately throw upon receiving 3+ SIGINT without clearing them
constexpr int SIGINTS_BEFORE_THROW = 3;

static sigset_t mask;
void SignalHandlerInit();
OutputSignal CheckSignalFlags();
Expand Down
Loading