From 4d1705e3a5cea72e15cb10e811e7c43b7b78ddf4 Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Wed, 20 Sep 2017 09:52:53 +0200
Subject: [PATCH] T: minor: close socket

Sometimes when the user does ctrl+c to quit, it may not quit
if nothing comes on the socket. Closing the socket in the
signal handler fixes this.
---
 common/utils/T/tracer/to_vcd.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/common/utils/T/tracer/to_vcd.c b/common/utils/T/tracer/to_vcd.c
index c7611162d2..82cd3393d7 100644
--- a/common/utils/T/tracer/to_vcd.c
+++ b/common/utils/T/tracer/to_vcd.c
@@ -4,6 +4,7 @@
 #include <stdint.h>
 #include <inttypes.h>
 #include <signal.h>
+#include <unistd.h>
 #include "database.h"
 #include "utils.h"
 #include "handler.h"
@@ -181,10 +182,13 @@ void usage(void)
 }
 
 int run = 1;
+static int socket = -1;
 
 void force_stop(int x)
 {
   printf("\ngently quit...\n");
+  close(socket);
+  socket = -1;
   run = 0;
 }
 
@@ -198,7 +202,6 @@ int main(int n, char **v)
   int *is_on;
   int number_of_events;
   int i;
-  int socket;
   vcd_vars vars[n];
   int nvars = 0;
   view *vcd_view;
-- 
GitLab