diff --git a/api/boinc_api.C b/api/boinc_api.C index cafbb5acfe..e87af33dbc 100644 --- a/api/boinc_api.C +++ b/api/boinc_api.C @@ -197,8 +197,9 @@ void boinc_catch_signal(int signal) { fprintf( stderr, "unknown signal %d", signal ); break; } + fprintf( stderr, "\nExiting...\n" ); #endif - exit(signal); + exit(ERR_SIGNAL_CATCH); } int boinc_finish(int status) { diff --git a/apps/concat.C b/apps/concat.C index 7d50e544e8..3028bf35ce 100644 --- a/apps/concat.C +++ b/apps/concat.C @@ -28,6 +28,7 @@ #include "filesys.h" #include "boinc_api.h" +#include "util.h" int run_slow = 0; diff --git a/apps/upper_case.C b/apps/upper_case.C index 3ea4e61e88..e6bdcc6d7d 100755 --- a/apps/upper_case.C +++ b/apps/upper_case.C @@ -23,6 +23,7 @@ // debugging // -cpu_time: app will chew up some CPU cycles after each character, // used for testing CPU time reporting +// -signal: app will raise SIGHUP signal (for testing signal handler) // // This version does one char/second, // and writes its state to disk every so often @@ -32,6 +33,7 @@ #include #include #include +#include #ifndef _WIN32 #include #endif @@ -71,7 +73,7 @@ char the_char[10]; double xPos=0, yPos=0; double xDelta=0.03, yDelta=0.07; -int run_slow=1,cpu_time=0; +int run_slow=0,cpu_time=0,raise_signal=0; time_t my_start_time; APP_INIT_DATA uc_aid; @@ -155,6 +157,7 @@ int main(int argc, char **argv) { fprintf(stderr, "APP: upper_case: argv[%d] is %s\n", i, argv[i]); if (!strcmp(argv[i], "-run_slow")) run_slow = 1; if (!strcmp(argv[i], "-cpu_time")) cpu_time = 1; + if (!strcmp(argv[i], "-signal")) raise_signal = 1; } in = fopen(resolved_name, "r"); boinc_resolve_filename(CHECKPOINT_FILE, resolved_name, sizeof(resolved_name)); @@ -202,6 +205,10 @@ int main(int argc, char **argv) { boinc_sleep(1); } + if (raise_signal) { + raise(SIGHUP); + } + if (boinc_time_to_checkpoint()) { retval = do_checkpoint(out, nchars); if (retval) { diff --git a/lib/error_numbers.h b/lib/error_numbers.h index 7d11e36f70..bbc699092e 100755 --- a/lib/error_numbers.h +++ b/lib/error_numbers.h @@ -49,3 +49,5 @@ #define ERR_DUP2 -121 #define ERR_NO_SIGNATURE -122 #define ERR_THREAD -123 +#define ERR_SIGNAL_CATCH -124 +