[netperf-dev] netperf2 commit notice r503 - trunk/src

raj at netperf.org raj at netperf.org
Wed Nov 23 14:20:01 PST 2011


Author: raj
Date: 2011-11-23 14:20:01 -0800 (Wed, 23 Nov 2011)
New Revision: 503

Modified:
   trunk/src/netlib.c
Log:
allow a timed test to be terminated cleanly via control-c

Modified: trunk/src/netlib.c
===================================================================
--- trunk/src/netlib.c	2011-11-10 01:00:08 UTC (rev 502)
+++ trunk/src/netlib.c	2011-11-23 22:20:01 UTC (rev 503)
@@ -919,9 +919,7 @@
   switch(sig) {
     
   case SIGINT:
-    fprintf(where,"netperf: caught SIGINT\n");
-    fflush(where);
-    exit(1);
+    times_up = 1;
     break;
   case SIGALRM: 
    if (--test_len_ticks == 0) {
@@ -1127,8 +1125,6 @@
 }
 
   action.sa_handler = catcher;
-  sigemptyset(&(action.sa_mask));
-  sigaddset(&(action.sa_mask),SIGALRM);
 
 #ifdef SA_INTERRUPT
   /* on some systems (SunOS 4.blah), system calls are restarted. we do */
@@ -1138,6 +1134,8 @@
   action.sa_flags = 0;
 #endif /* SA_INTERRUPT */
 
+  sigemptyset(&(action.sa_mask));
+  sigaddset(&(action.sa_mask),SIGALRM);
   if (sigaction(SIGALRM, &action, NULL) < 0) {
     fprintf(where,
 	    "start_timer: error installing alarm handler errno %d\n",
@@ -1146,6 +1144,16 @@
     exit(-1);
   }
 
+  sigemptyset(&(action.sa_mask));
+  sigaddset(&(action.sa_mask),SIGINT);
+  if (sigaction(SIGINT, &action, NULL) < 0) {
+    fprintf(where,
+	    "start_timer: error installing SIGINT handler errno %d\n",
+	    errno);
+    fflush(where);
+    exit(-1);
+  }
+
   /* this is the easy case - just set the timer for so many seconds */ 
   ret = alarm(time);
   if (ret != 0) {



More information about the netperf-dev mailing list