aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPete Zaitcev <zaitcev@kotori.zaitcev.us>2018-05-13 15:19:31 -0500
committerSteve Markgraf <steve@steve-m.de>2018-05-23 23:20:26 +0200
commitce9595ef537f9f69a88425f97c9e4179ac9db769 (patch)
treeea112553d4805d2488913aa514d536391f6a24cb
parenta854ae8b48d42e8dad514c75d3a4c6cfb62707da (diff)
rtl_adsb: fix hanging upon a signal in Fedora 27
This code stayed unchanged for many years, but for some reason rtl_adsb started hanging upon exit: *b66116a5164b69281eacc42ae950; ^CSignal caught, exiting! <------ hangs here forever Examining it with gdb reveals that the demod thread waits peacefully on the condition variable, which we're trying to destroy. Either the signals killed all threads before, or condition variables were possible to destroy while other threads still waited on them. The easiest fix appears to be just cancel the demod thread and wait for it to exit before proceeding for the door. Signed-off-by: Steve Markgraf <steve@steve-m.de>
-rw-r--r--src/rtl_adsb.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/rtl_adsb.c b/src/rtl_adsb.c
index 07fdd2a..9087de4 100644
--- a/src/rtl_adsb.c
+++ b/src/rtl_adsb.c
@@ -492,6 +492,8 @@ int main(int argc, char **argv)
else {
fprintf(stderr, "\nLibrary error %d, exiting...\n", r);}
rtlsdr_cancel_async(dev);
+ pthread_cancel(demod_thread);
+ pthread_join(demod_thread, NULL);
pthread_cond_destroy(&ready);
pthread_mutex_destroy(&ready_m);