Changeset 2cf30f6 for tools/tracereport


Ignore:
Timestamp:
09/02/07 01:44:31 (14 years ago)
Author:
Perry Lorier <perry@…>
Branches:
4.0.1-hotfixes, cachetimestamps, develop, dpdk-ndag, etsilive, getfragoff, help, libtrace4, master, ndag_format, pfring, rc-4.0.1, rc-4.0.2, rc-4.0.3, rc-4.0.4, ringdecrementfix, ringperformance, ringtimestampfixes
Children:
52656ed
Parents:
cd1fd75
Message:

Add signal handling to more programs that could use it.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/tracereport/tracereport.c

    r466aed6 r2cf30f6  
    4343#include <getopt.h>
    4444#include <inttypes.h>
    45 //#include "lt_inttypes.h"
     45#include <signal.h>
    4646
    4747#include "libtrace.h"
     
    5151struct libtrace_t *trace;
    5252uint32_t reports_required = 0;
     53
     54static volatile int done=0;
     55
     56static void cleanup_signal(int sig)
     57{
     58        done=1;
     59}
    5360
    5461/* Process a trace, counting packets that match filter(s) */
     
    8188                        break;
    8289                */
     90                if (done)
     91                        break;
    8392                if ((psize = trace_read_packet(trace, packet)) <1) {
    8493                        break;
     
    142151        int opt;
    143152        char *filterstring=NULL;
     153        struct sigaction sigact;
    144154
    145155        libtrace_filter_t *filter = NULL;/*trace_bpf_setfilter(filterstring); */
     
    231241                filter = trace_create_filter(filterstring);
    232242        }
     243
     244        sigact.sa_handler = cleanup_signal;
     245        sigemptyset(&sigact.sa_mask);
     246        sigact.sa_flags = SA_RESTART;
     247
     248        sigaction(SIGINT, &sigact, NULL);
     249        sigaction(SIGTERM, &sigact, NULL);
    233250               
    234251       
Note: See TracChangeset for help on using the changeset viewer.