From 7c16c8cbe6a2b701e66d52b407fee4b7ed2065b2 Mon Sep 17 00:00:00 2001 From: Guolin Yang Date: Mon, 9 Sep 2013 09:38:01 -0700 Subject: [PATCH] util: Don't set thread name to empty In monitor_daemon(), it set subprogram_name to "" which causes system crash in some platform when trying to set the thread name to "". This change set thread name to program name in this case. Signed-off-by: Guolin Yang Signed-off-by: Ben Pfaff --- lib/util.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/util.c b/lib/util.c index 3cada4ad4..b8004555f 100644 --- a/lib/util.c +++ b/lib/util.c @@ -405,13 +405,14 @@ get_subprogram_name(void) void set_subprogram_name(const char *name) { + const char *pname = name[0] ? name : program_name; free(subprogram_name_set(xstrdup(name))); #if HAVE_GLIBC_PTHREAD_SETNAME_NP - pthread_setname_np(pthread_self(), name); + pthread_setname_np(pthread_self(), pname); #elif HAVE_NETBSD_PTHREAD_SETNAME_NP - pthread_setname_np(pthread_self(), "%s", name); + pthread_setname_np(pthread_self(), "%s", pname); #elif HAVE_PTHREAD_SET_NAME_NP - pthread_set_name_np(pthread_self(), name); + pthread_set_name_np(pthread_self(), pname); #endif } -- 2.20.1