diff --git a/src/iothread.cpp b/src/iothread.cpp index 429522fa7..1ba046627 100644 --- a/src/iothread.cpp +++ b/src/iothread.cpp @@ -362,10 +362,14 @@ bool make_detached_pthread(void *(*func)(void *), void *param) { err = pthread_create(&thread, &thread_attr, func, param); if (err == 0) { FLOGF(iothread, "pthread %d spawned", thread); - pthread_attr_destroy(&thread_attr); } else { perror("pthread_create"); } + int err2 = pthread_attr_destroy(&thread_attr); + if (err2 != 0) { + perror("pthread_attr_destroy"); + err = err2; + } } else { perror("pthread_attr_setdetachstate"); }