Changeset 2cf30f6 for tools


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.

Location:
tools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • tools/tracemerge/tracemerge.c

    re2d49d5 r2cf30f6  
    55#include <stdbool.h>
    66#include <getopt.h>
     7#include <signal.h>
    78
    89static void usage(char *argv0)
     
    1516        ,argv0);
    1617        exit(1);
     18}
     19
     20volatile int done=0;
     21
     22static void cleanup_signal(int sig)
     23{
     24        done=1;
    1725}
    1826
     
    2836        int i=0;
    2937        uint64_t last_ts=0;
     38        struct sigaction sigact;
    3039
    3140        while (1) {
     
    7281        }
    7382
     83        sigact.sa_handler = cleanup_signal;
     84        sigemptyset(&sigact.sa_mask);
     85        sigact.sa_flags = SA_RESTART;
     86
     87        sigaction(SIGINT,&sigact,NULL);
     88        sigaction(SIGTERM,&sigact,NULL);
     89
    7490        input=calloc((size_t)(argc-optind),sizeof(struct libtrace_t *));
    7591        packet=calloc((size_t)(argc-optind),sizeof(struct libtrace_packet_t *));
     
    97113                uint64_t oldest_ts=0;
    98114                int oldest=-1;
     115                if (done)
     116                        break;
    99117                for(i=0;i<argc-optind;++i) {
    100118                        if (!live[i] && input[i]) {
  • 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       
  • tools/tracestats/tracestats.c

    rd242ea8 r2cf30f6  
    5151#include <getopt.h>
    5252#include <inttypes.h>
     53#include <signal.h>
    5354
    5455#include "libtrace.h"
     
    5960
    6061struct libtrace_t *trace;
     62
     63volatile static int done=0;
     64
     65static void cleanup_signal(int signal)
     66{
     67        done=1;
     68}
    6169
    6270struct filter_t {
     
    98106                        break;
    99107                }
     108               
     109                if (done)
     110                        break;
    100111
    101112                for(i=0;i<filter_count;++i) {
     
    138149
    139150        int i;
     151        struct sigaction sigact;
    140152
    141153        while(1) {
     
    173185        }
    174186
     187        sigact.sa_handler = cleanup_signal;
     188        sigemptyset(&sigact.sa_mask);
     189        sigact.sa_flags = SA_RESTART;
     190
     191        sigaction(SIGINT, &sigact, NULL);
     192        sigaction(SIGTERM, &sigact, NULL);
     193
    175194        for(i=optind;i<argc;++i) {
    176195                run_trace(argv[i]);
Note: See TracChangeset for help on using the changeset viewer.