X-Git-Url: https://git.lttng.org/?p=lttng-tools.git;a=blobdiff_plain;f=src%2Fcommon%2Fthread.cpp;fp=src%2Fcommon%2Fthread.cpp;h=34a620679d258a1e72035416f67ed85310473ba4;hp=0000000000000000000000000000000000000000;hb=a6bc4ca9d659caf016ef932fcd944029737ac57c;hpb=97535efaa975ca52bf02c2d5e76351bfd2e3defa diff --git a/src/common/thread.cpp b/src/common/thread.cpp new file mode 100644 index 000000000..34a620679 --- /dev/null +++ b/src/common/thread.cpp @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2020 Michael Jeanson + * + * SPDX-License-Identifier: LGPL-2.1-only + * + */ + +#include + +#include +#include "thread.h" + + +int lttng_thread_setname(const char *name) +{ + int ret; + char pthread_name[LTTNG_PTHREAD_NAMELEN]; + + /* + * Truncations are expected since pthread limits thread names to + * a generous 16 characters. + */ + strncpy(pthread_name, name, sizeof(pthread_name)); + pthread_name[sizeof(pthread_name) - 1] = '\0'; + + ret = lttng_pthread_setname_np(pthread_name); + + return ret; +} +