Commit f84155f7da8cc48ac1c0031cc479b2f018354a07

Thomas de Grivel 2020-02-18T14:12:22

try to stop at start in case run failed and we need to join thread

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
diff --git a/rtbuf_cli.c b/rtbuf_cli.c
index eaef2fc..e26add4 100644
--- a/rtbuf_cli.c
+++ b/rtbuf_cli.c
@@ -233,6 +233,11 @@ int rtbuf_cli_start (int argc, const char *argv[])
   (void) argv;
   if (argc != 0)
     return rtbuf_err("usage: start");
+  if (!g_rtbuf_run && g_rtbuf_cli_thread) {
+    if (pthread_join(g_rtbuf_cli_thread, 0))
+      return rtbuf_err("pthread_join failed");
+    g_rtbuf_cli_thread = 0;
+  }
   if (!g_rtbuf_cli_thread) {
     if (pthread_create(&g_rtbuf_cli_thread, 0, &rtbuf_cli_thread_proc,
                        0))