Commit 62cbf1dc authored by Andreas Schmidt's avatar Andreas Schmidt

Add SIGINT handler to sender.

parent 335eee9a
Pipeline #2667 failed with stages
in 1 minute and 46 seconds
#include <stdio.h>
#include <string.h>
#include <stdint.h>
#include <signal.h>
#include <argp.h>
#include "util/dbg.h"
#include "proto/socket.h"
PrrtSocket *s = NULL;
static volatile int keepRunning = true;
static char doc[] = "PRRT Sender";
static struct argp_option options[] = {
......@@ -69,8 +73,14 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
return 0;
}
void intHandler(int dummy) {
keepRunning = false;
PrrtSocket_interrupt(s);
}
int main(int argc, char **argv) {
signal(SIGINT, intHandler);
struct argp argp = { options, parse_opt, args_doc, doc };
struct arguments arguments = {
......@@ -101,7 +111,7 @@ int main(int argc, char **argv) {
#endif
PrrtSocket *s = PrrtSocket_create(1400, 10 * 1000 * 1000);
s = PrrtSocket_create(1400, 10 * 1000 * 1000);
check(s != NULL, "Socket create failed.");
if(strcmp(arguments.hardwarestamping_interface, "-") != 0) {
......@@ -126,7 +136,7 @@ int main(int argc, char **argv) {
XlapTimestampTableInstall(s, ts_redundancy_packet, tstable_redundancy);
uint32_t j = 0;
while (j < rounds) {
while (j < rounds && keepRunning) {
char buf[MAX_PAYLOAD_LENGTH];
// 1400 bytes.
sprintf(buf, "%1400d", j + 1);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment