Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Catch SIGTERM and schedule checkpoint and finish. #35

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
23 changes: 22 additions & 1 deletion ParallelGravity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,9 @@ void _Trailer(void) {
int killAt;
int cacheSize;

/// @brief function to enable stopping on SIGTERM
void fnCatchSigTerm(int);

///
/// @brief Main routine to start simulation.
///
Expand All @@ -226,7 +229,9 @@ Main::Main(CkArgMsg* m) {
bChkFirst = 1;
dSimStartTime = CkWallTimer();

int threadNum = CkMyNodeSize();
signal(SIGTERM, fnCatchSigTerm);

int threadNum = CkMyNodeSize();

// Floating point exceptions.
// feenableexcept(FE_OVERFLOW | FE_DIVBYZERO | FE_INVALID);
Expand Down Expand Up @@ -2241,8 +2246,24 @@ void Main::setupICs() {
initialForces();
}

/// @brief indicate that SIGTERM was caught
volatile sig_atomic_t iGotSigTerm = 0;

void fnCatchSigTerm(int iSignal)
{
iGotSigTerm = 1;
}

int CheckForStop()
{
/*
* First check for signal
*/
if(iGotSigTerm == 1) {
CkPrintf("TERM signal received\n");
return 1;
}

/*
** Checks for existence of STOPFILE in run directory. If
** found, the file is removed and the return status is set
Expand Down