With Kill Signals

For long-running programs, the saving of coverage data can be triggered during the termination of the program by a kill signal like Control-C.

Depending on the operating system and the concrete "kill signal", the atexit() testimonial function is called by the system or not.

If it is called, the coverage data is saved as in the default way, at the end of the program execution.

If not, the following arrangement can be used if the saving of coverage data shall be triggered. The instrumentation can be done for example like this:
ctcwrap ... -C OPT_ADD_COMPILE+-DCTC_LAUNCH_APPENDER \
            -C LIBRARY+appendtrigger.obj make ...
You need to edit and compile (as C code, not C++ code) the appendtrigger.c file. It could look as in the following example (For Linux, here a new handler is assigned on segment violation SIGSEGV signal. Adjust the code for your needs):
/*Example for appendtrigger.c */
#include <signal.h>
#include "ctc.h"

static void (*oldhandler)(int)=SIG_DFL; /* Default handler */

static void my_handler(int);

void ctc_append_trigger(void) {
  static int first_time = 1;
  if (first_time == 1) {
    first_time = 0;
    oldhandler=signal(SIGSEGV, my_handler);
  }
  return;
}
static void my_handler(int i) {
  ctc_append_all(); /* first write out coverage data  */
  oldhandler(i);    /* then do what was normally done */
}