diff --git a/klippy/chelper/__init__.py b/klippy/chelper/__init__.py index 2aed107a..de8a496a 100644 --- a/klippy/chelper/__init__.py +++ b/klippy/chelper/__init__.py @@ -219,6 +219,7 @@ defs_trdispatch = """ defs_pyhelper = """ void set_python_logging_callback(void (*func)(const char *)); double get_monotonic(void); + int set_thread_name(char name[16]); """ defs_std = """ diff --git a/klippy/chelper/pyhelper.c b/klippy/chelper/pyhelper.c index a0a42923..60c6de9b 100644 --- a/klippy/chelper/pyhelper.c +++ b/klippy/chelper/pyhelper.c @@ -10,6 +10,8 @@ #include // fprintf #include // strerror #include // struct timespec +#include // PR_SET_NAME +#include // prctl #include "compiler.h" // __visible #include "pyhelper.h" // get_monotonic @@ -92,3 +94,10 @@ dump_string(char *outbuf, int outbuf_size, char *inbuf, int inbuf_size) *o = '\0'; return outbuf; } + +// Set custom thread names +int __visible +set_thread_name(char name[16]) +{ + return prctl(PR_SET_NAME, name); +} diff --git a/klippy/chelper/pyhelper.h b/klippy/chelper/pyhelper.h index 1042214b..a29992a2 100644 --- a/klippy/chelper/pyhelper.h +++ b/klippy/chelper/pyhelper.h @@ -7,5 +7,6 @@ void set_python_logging_callback(void (*func)(const char *)); void errorf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2))); void report_errno(char *where, int rc); char *dump_string(char *outbuf, int outbuf_size, char *inbuf, int inbuf_size); +int set_thread_name(char name[16]); #endif // pyhelper.h