Minor changes

This commit is contained in:
Loic Guegan 2023-07-16 14:50:53 +02:00
parent e0fdde7cd0
commit 33c5443794
4 changed files with 37 additions and 6 deletions

View file

@ -2,9 +2,17 @@
#include <assert.h>
#include <time.h>
#include <string.h>
#include <signal.h>
#include "utils.h"
unsigned char __stop=0;
void sighandler(int signo){
if (signo == SIGINT){
printf("Stopping...\n");
__stop=1;
}
}
int main (int argc, char *argv [])
{
if(argc != 3){
@ -18,6 +26,7 @@ int main (int argc, char *argv [])
//----- Various inits
mkdirp(cdatadir);
signal(SIGINT,sighandler);
//----- Init ZMQ
void *context = zmq_ctx_new ();
@ -35,8 +44,10 @@ int main (int argc, char *argv [])
//----- Listen
char buffer[ZMQ_MSG_SIZE];
int size;
while(1){
while(!__stop){
size=zmq_recv (subscriber, buffer, ZMQ_MSG_SIZE-1, 0);
if(size<=0)
continue;
buffer[size < ZMQ_MSG_SIZE ? size : ZMQ_MSG_SIZE - 1] = '\0';
//----- Read buffer
char *token = strtok(buffer, "\n");