SWDEV-445415 - Pthread detach instead of pthread join

Detcah the thread which handle shutdown signals instead of joining
thread can avoid the segfault issue on specific ASIC.

Signed-off-by: Li Ma <li.ma@amd.com>
Change-Id: I74ac53c027ac370605caaa87115c83fd8027526a
This commit is contained in:
Li Ma
2024-09-11 11:14:52 +08:00
committed by Dmitrii Galantsev
parent b5df3a2135
commit ca569346a3
+7 -9
View File
@@ -663,21 +663,19 @@ int main(int argc, char** argv) {
return 1;
}
// Detach the thread, sys will recycle the resource
thr_ret = pthread_detach(sig_listen_thread);
// Don't fail if detach is not successful
if (thr_ret !=0) {
std::cerr << "Failed to detach ProcessSignalLoop. pthread_detach() returned " << thr_ret;
}
// TODO(cfreehil): Eventually, set these by reading a config file
rdc_server.set_start_rdc_admin_service(true);
rdc_server.set_start_api_service(true);
rdc_server.Run();
// join the thread to prevent the program terminated
void* ret = nullptr;
thr_ret = pthread_join(sig_listen_thread, &ret);
// don't fail if it doesn't succeed
if (thr_ret != 0) {
std::cerr << "Failed to terminate ProcessSignalLoop. pthread_join() returned " << thr_ret;
}
if (sShutDownServer) {
std::cout << "RDC server successfully shut down." << std::endl;
return 0;