2 * SPDX-License-Identifier: LGPL-2.1-only
4 * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 * Copyright (C) 2016 Raphaƫl Beamonte <raphael.beamonte@gmail.com>
6 * Copyright (C) 2020 Michael Jeanson <mjeanson@efficios.com>
9 #ifndef _UST_COMMON_PROCNAME_H
10 #define _UST_COMMON_PROCNAME_H
13 #include <lttng/ust-abi.h>
15 #include "common/compat/pthread.h"
17 #define LTTNG_UST_PROCNAME_SUFFIX "-ust"
20 * If a pthread setname/set_name function is available, declare
21 * the setustprocname() function that will add '-ust' to the end
22 * of the current process name, while truncating it if needed.
25 int lttng_ust_setustprocname(void)
28 char name
[LTTNG_UST_ABI_PROCNAME_LEN
];
29 int limit
= LTTNG_UST_ABI_PROCNAME_LEN
- strlen(LTTNG_UST_PROCNAME_SUFFIX
) - 1;
32 * Get the current thread name.
34 ret
= lttng_pthread_getname_np(name
, LTTNG_UST_ABI_PROCNAME_LEN
);
44 ret
= sprintf(name
+ len
, LTTNG_UST_PROCNAME_SUFFIX
);
45 if (ret
!= strlen(LTTNG_UST_PROCNAME_SUFFIX
)) {
49 ret
= lttng_pthread_setname_np(name
);
55 #endif /* _UST_COMMON_PROCNAME_H */