Changeset a8cfe71


Ignore:
Timestamp:
12/14/17 11:21:41 (2 years ago)
Author:
Shane Alcock <salcock@…>
Branches:
cachetimestamps, develop, dpdk-ndag, etsilive, master, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance
Children:
e940b4f
Parents:
92cf299
Message:

Add proper SIGINT / SIGTERM handling to tracertstats

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/tracertstats/tracertstats.c

    r8e11beb ra8cfe71  
    4747#include <getopt.h>
    4848#include <inttypes.h>
     49#include <signal.h>
     50
    4951#include <lt_inttypes.h>
    50 
    5152#include "libtrace_parallel.h"
    5253#include "output.h"
     
    8081uint64_t count;
    8182uint64_t bytes;
     83
     84struct libtrace_t *currenttrace;
     85
     86static void cleanup_signal(int signal UNUSED) {
     87        if (currenttrace) {
     88                trace_pstop(currenttrace);
     89        }
     90}
    8291
    8392static void report_results(double ts,uint64_t count,uint64_t bytes)
     
    281290        trace_set_result_cb(repcbs, cb_result);
    282291
     292        currenttrace = trace;
    283293        if (trace_pstart(trace, NULL, pktcbs, repcbs)==-1) {
    284294                trace_perror(trace,"Failed to start trace");
     
    329339
    330340        int i;
     341        struct sigaction sigact;
    331342       
    332343        while(1) {
     
    414425                        return 0;
    415426        }
    416                
     427       
     428        sigact.sa_handler = cleanup_signal;
     429        sigemptyset(&sigact.sa_mask);
     430        sigact.sa_flags = SA_RESTART;
     431
     432        sigaction(SIGINT, &sigact, NULL);
     433        sigaction(SIGTERM, &sigact, NULL);
     434
     435
    417436        for(i=optind;i<argc;++i) {
    418437                run_trace(argv[i]);
Note: See TracChangeset for help on using the changeset viewer.