From: c vw <dl1ycf@darc.de>
Date: Tue, 26 May 2020 16:41:57 +0000 (+0200)
Subject: RigCtl: made "waiting" for the serial thread even more secure.
X-Git-Url: https://git.rkrishnan.org/specifications/components/flags/%22doc.html/module-simplejson.html?a=commitdiff_plain;h=07550cd7556fde129439653ffa2027932978247b;p=pihpsdr.git

RigCtl: made "waiting" for the serial thread even more secure.
---

diff --git a/rigctl.c b/rigctl.c
index 58787b0..6b90735 100644
--- a/rigctl.c
+++ b/rigctl.c
@@ -3987,8 +3987,11 @@ int launch_serial () {
 void disable_serial () {
      g_print("RIGCTL: Disable Serial port %s\n",ser_port);
      serial_running=FALSE;
-     g_thread_join(serial_server_thread_id);
-     close(fd);
+     // wait for the serial server actually terminating
+     if (serial_server_thread_id) {
+       g_thread_join(serial_server_thread_id);
+     }
+     serial_server_thread_id=NULL;
 }
 
 //