Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

If we receive a signal, we re-register ALL previous signal handlers.

This fixes the case when we pass signal to previously registered
handler, and it needs to transform the signal into different one.

Still problematic: What if the signal handler we replaced does not
terminate the application? We can end up in a weird state and loop
forever.

Possible solution: Deregister our signal handlers, CALL the previous
signal handler explicitly and if control returns, abort. This would
however complicate our code quite a bit, as we would have to parse the
sigaction we delegate to, decide whether to use signal handler or signal
action, etc...
Commit
ffc4a9dc143bc66d2e1fd883e1395a3397a68e9d
Author
Martin Hořeňovský ·
Parents
7c8b93eac3e6

Files · Download .tar.gz

Changes

 include/internal/catch_fatal_condition.hpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/include/internal/catch_fatal_condition.hpp b/include/internal/catch_fatal_condition.hpp
index 895b662d..f99c8f26 100644
--- a/include/internal/catch_fatal_condition.hpp
+++ b/include/internal/catch_fatal_condition.hpp
@@ -118,10 +118,10 @@ namespace Catch {
                 SignalDefs &def = signalDefs[i];
                 if (sig == def.id) {
                     name = def.name;
-                    sigaction(def.id, &oldSigActions[i], CATCH_NULL);
                     break;
                 }
             }
+            reset();
             reportFatal(name, -sig);
             raise( sig );
         }
@@ -146,7 +146,7 @@ namespace Catch {
         ~FatalConditionHandler() {
             reset();
         }
-        void reset() {
+        static void reset() {
             if( isSet ) {
                 // Set signals back to previous values -- hopefully nobody overwrote them in the meantime
                 for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) {