From 00ff114cabf091fbb108d77d57699ec6e2c0f72c Mon Sep 17 00:00:00 2001 From: DL6ER Date: Tue, 9 Jul 2024 18:58:55 +0200 Subject: [PATCH] Do not start threads in detached mode. Joining them may SEGFAULT with libmusl Signed-off-by: DL6ER --- src/dnsmasq_interface.c | 4 +--- src/tools/arp-scan.c | 2 -- src/tools/dhcp-discover.c | 2 -- 3 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/dnsmasq_interface.c b/src/dnsmasq_interface.c index 72bb41ce..c3803f46 100644 --- a/src/dnsmasq_interface.c +++ b/src/dnsmasq_interface.c @@ -2912,12 +2912,10 @@ void FTL_fork_and_bind_sockets(struct passwd *ent_pw, bool dnsmasq_start) // so they will not listen to real-time signals handle_realtime_signals(); - // We will use the attributes object later to start all threads in - // detached mode - pthread_attr_t attr; // Initialize thread attributes object with default attribute values // Do NOT detach threads as we want to join them during shutdown with a // fixed timeout to give them time to clean up and finish their work + pthread_attr_t attr; pthread_attr_init(&attr); // Initialize NTP server diff --git a/src/tools/arp-scan.c b/src/tools/arp-scan.c index c5ac6ec3..923625a3 100644 --- a/src/tools/arp-scan.c +++ b/src/tools/arp-scan.c @@ -616,8 +616,6 @@ int run_arp_scan(const bool scan_all, const bool extreme_mode) pthread_attr_t attr; // Initialize thread attributes object with default attribute values pthread_attr_init(&attr); - // Set thread attributes to detached mode - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); struct ifaddrs *addrs, *tmp; getifaddrs(&addrs); diff --git a/src/tools/dhcp-discover.c b/src/tools/dhcp-discover.c index 045c8c14..c68a74f9 100644 --- a/src/tools/dhcp-discover.c +++ b/src/tools/dhcp-discover.c @@ -725,8 +725,6 @@ int run_dhcp_discover(void) pthread_attr_t attr; // Initialize thread attributes object with default attribute values pthread_attr_init(&attr); - // Set thread attributes to detached mode - pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED); // Create processing/printfing lock pthread_mutexattr_t lock_attr;