#include <stdlib.h>
#include <time.h>
#include <string.h>
+#include <signal.h>
#include "mcl.h"
fprintf( stderr, " -s stats only mode\n" );
}
+/*
+ We exit on any trapped signal so that we can kill -15 the proecss
+ and still get gcoverage information to keep sonar happy.
+*/
+static void sigh( int sig ) {
+ fprintf( stderr, "\n[INFO] exiting on signal %d\n", sig );
+ exit( 0 );
+}
+
//------------------------------------------------------------------------------------------
int main( int argc, char** argv ) {
void* ctx; // the mc listener library context
long count = 0;
int blabber = 0;
+ signal( SIGINT, sigh );
+ signal( SIGTERM, sigh );
+
while( pidx < argc && argv[pidx][0] == '-' ) { // simple argument parsing (-x or -x value)
switch( argv[pidx][1] ) {
case 'd':
if( pidx+1 < argc ) {
dname = strdup( argv[pidx+1] );
- pidx++;
+ pidx++;
} else {
- bad_arg( argv[pidx] );
+ bad_arg( argv[pidx] );
error = 1;
- }
+ }
break;
case 'e':
case 'm':
if( pidx+1 < argc ) {
mtype = atoi( argv[pidx+1] );
- pidx++;
+ pidx++;
} else {
- bad_arg( argv[pidx] );
+ bad_arg( argv[pidx] );
error = 1;
- }
+ }
break;
case 's':
case '?':
usage( argv[0] );
exit( 0 );
- break;
default:
bad_arg( argv[pidx] );
usage( argv[0] );
exit( 1 );
}
-
+
ctx = mcl_mk_context( dname ); // initialise the library context
if( ctx == NULL ) {
fprintf( stderr, "[FAIL] couldn't initialise the mc listener library" );
count++;
}
}
-
- fprintf( stderr, "[INFO] mc listener is finished.\n" );
}