From ffc9ca559120e694809b2a69c45dc5a17034f539 Mon Sep 17 00:00:00 2001 From: Robert Falkenberg Date: Tue, 20 Sep 2022 11:50:12 +0200 Subject: [PATCH] threads: don't join thread if pthread_create failed; fix error messages --- lib/src/common/threads.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/src/common/threads.c b/lib/src/common/threads.c index 8ae786848..fe83380fa 100644 --- a/lib/src/common/threads.c +++ b/lib/src/common/threads.c @@ -146,18 +146,17 @@ bool threads_new_rt_cpu(pthread_t* thread, void* (*start_routine)(void*), void* int err = pthread_create(thread, attr_enable ? &attr : NULL, start_routine, arg); if (err) { if (EPERM == err) { - // Join failed thread for avoiding memory leak from previous trial - pthread_join(*thread, NULL); - - perror("Warning: Failed to create thread with real-time priority. Creating it with normal priority"); + fprintf(stderr, + "Warning: Failed to create thread with real-time priority. Creating it with normal priority: %s\n", + strerror(err)); err = pthread_create(thread, NULL, start_routine, arg); if (err) { - perror("pthread_create"); + fprintf(stderr, "Error: Failed to create thread with normal priority: %s\n", strerror(err)); } else { ret = true; } } else { - perror("pthread_create"); + fprintf(stderr, "Error: Failed to create thread with real-time priority: %s\n", strerror(err)); } } else { ret = true;