summaryrefslogtreecommitdiff
path: root/log-replayer
diff options
context:
space:
mode:
authorMarco Residori <marco.residori@xse.de>2014-06-24 16:03:57 +0200
committerMarco Residori <marco.residori@xse.de>2014-06-24 16:03:57 +0200
commit355aea9c48fb89007681635f98b62c0045f0c63c (patch)
tree092cbcc25acd0bad697c2610b338bba1f86ca4bc /log-replayer
parent40c43fd3ae2210a2cfc634cf6628e97fbcd41d93 (diff)
downloadpositioning-355aea9c48fb89007681635f98b62c0045f0c63c.tar.gz
Add new version of enhanced-position-service using libdbus-c++ instead of Qt
Diffstat (limited to 'log-replayer')
-rw-r--r--log-replayer/src/log-replayer.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/log-replayer/src/log-replayer.c b/log-replayer/src/log-replayer.c
index bf24c60..ab1370a 100644
--- a/log-replayer/src/log-replayer.c
+++ b/log-replayer/src/log-replayer.c
@@ -19,6 +19,7 @@
#include <arpa/inet.h>
#include <netinet/in.h>
#include <stdio.h>
+#include <signal.h>
#include <stdlib.h>
#include <stdbool.h>
#include <sys/types.h>
@@ -36,6 +37,14 @@
DLT_DECLARE_CONTEXT(gContext);
+bool running = true;
+
+void sighandler(int sig)
+{
+ LOG_INFO_MSG(gContext,"Signal received");
+ running = false;
+}
+
bool getStrToSend(FILE* file, char* line, int dim)
{
static long unsigned int lastTimestamp = 0;
@@ -111,6 +120,9 @@ int main(int argc, char* argv[])
char buf[BUFLEN];
char msgId[MSGIDLEN];
+ signal(SIGTERM, sighandler);
+ signal(SIGINT, sighandler);
+
if(argc < 2)
{
LOG_ERROR_MSG(gContext,"missing input parameter: logfile");
@@ -151,7 +163,7 @@ int main(int argc, char* argv[])
LOG_INFO(gContext,"Started reading log file %s",filename);
- while(1)
+ while(running)
{
if(!getStrToSend(logfile,buf,BUFLEN))
{