Skip to content

Commit

Permalink
Ehance signal handling capability
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamSimpson committed Nov 10, 2015
1 parent e75d8a3 commit 7ec62e1
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 11 deletions.
42 changes: 32 additions & 10 deletions src/split.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,28 +141,38 @@ static void CloseStdOutErr() {
// Calling MPI_Finalize and fprintf is undefined
// Cleanup operations have been problematic so are skipped
static void SegvHandler(int sig) {
// If the process receives another SEGV throw in the towel
signal(SIGSEGV, SIG_DFL);

fprintf(stderr, "*********\n ERROR: Signal SEGV Received\n*********\n");

MPI_Finalize();
if(getenv("W_SIG_DFL"))
signal(SIGSEGV, SIG_DFL);

// Try to clean up
MPI_Finalize();
_exit(EXIT_SUCCESS);
}

// Handle SIGABRT, to handle a call to abort() for instance
static void AbrtHandler(int sig) {
// If the process receives another ABRT throw in the towel
signal(SIGABRT, SIG_DFL);

fprintf(stderr, "*********\n ERROR: Signal SIGABRT Received\n*********\n");

MPI_Finalize();
if(getenv("W_SIG_DFL"))
signal(SIGSEGV, SIG_DFL);

// Try to clean up
MPI_Finalize();
exit(EXIT_SUCCESS);
}

static void SegvHandlerPause(int sig) {
fprintf(stderr, "*********\n ERROR: Signal SEGV Received\n*********\n");
pause();
}

static void AbrtHandlerPause(int sig) {
fprintf(stderr, "*********\n ERROR: Signal Abrt Received\n*********\n");
pause();
}

// For an exit code of 0, any process with non 0 exit will abort entire wraprun
// Works for exit() or return()
static void ExitHandler() {
Expand Down Expand Up @@ -198,13 +208,25 @@ static void SplitInit() {
SetStdOutErr(color);

if (getenv("W_IGNORE_SEGV")) {
sighandler_t err_sig = signal(SIGSEGV, SegvHandler);
sighandler_t err_sig;

if(getenv("W_SIG_PAUSE"))
err_sig = signal(SIGSEGV, SegvHandlerPause);
else
err_sig = signal(SIGSEGV, SegvHandler);

if(err_sig == SIG_ERR)
fprintf(stderr, "ERROR REGISTERING SIGSEGV HANDLER!\n");
}

if (getenv("W_IGNORE_ABRT")) {
sighandler_t err_abrt = signal(SIGABRT, AbrtHandler);
sighandler_t err_abrt;

if(getenv("W_SIG_PAUSE"))
err_abrt = signal(SIGABRT, AbrtHandlerPause);
else
err_abrt = signal(SIGABRT, AbrtHandlerPause);

if(err_abrt == SIG_ERR)
fprintf(stderr, "ERROR REGISTERING SIGARBT HANDLER!\n");
}
Expand Down
3 changes: 2 additions & 1 deletion wraprun_formula.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class WraprunFormula < Formula
homepage "https://github.com/olcf/wraprun"
url "https://github.com/olcf/wraprun/archive/v0.1.7.tar.gz"
url "https://github.com/olcf/wraprun/archive/v0.1.8.tar.gz"

concern for_version("dev") do
included do
Expand Down Expand Up @@ -94,6 +94,7 @@ module load dynamic-link
setenv W_IGNORE_SEGV 1
setenv W_IGNORE_RETURN_CODE 1
setenv W_IGNORE_ABRT 1
setenv W_SIG_DFL 1
<% if @builds.size > 1 %>
<%= module_build_list @package, @builds %>
Expand Down

0 comments on commit 7ec62e1

Please sign in to comment.