From 4939a44ffb4b425f91b6ca8bd9216b836ec280f5 Mon Sep 17 00:00:00 2001 From: Nils <> Date: Fri, 26 Jun 2020 19:51:30 +0200 Subject: [PATCH] Also set pthread name in startup, for what it is worth --- engine/start.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/engine/start.py b/engine/start.py index ebfb30f..9d592c1 100644 --- a/engine/start.py +++ b/engine/start.py @@ -152,7 +152,7 @@ def setProcessName(executableName): """From https://stackoverflow.com/questions/31132342/change-process-name-while-executing-a-python-script """ - import ctypes + import ctypes, ctypes.util lib = ctypes.cdll.LoadLibrary(None) prctl = lib.prctl prctl.restype = ctypes.c_int @@ -164,6 +164,28 @@ def setProcessName(executableName): raise OSError("prctl result: %d" % result) set_proctitle(executableName.encode()) + + libpthread_path = ctypes.util.find_library("pthread") + if not libpthread_path: + return + + libpthread = ctypes.CDLL(libpthread_path) + if hasattr(libpthread, "pthread_setname_np"): + _pthread_setname_np = libpthread.pthread_setname_np + + _pthread_self = libpthread.pthread_self + _pthread_self.argtypes = [] + _pthread_self.restype = ctypes.c_void_p + + _pthread_setname_np.argtypes = [ctypes.c_void_p, ctypes.c_char_p] + _pthread_setname_np.restype = ctypes.c_int + + if _pthread_setname_np is None: + return + + _pthread_setname_np(_pthread_self(), executableName.encode()) + + def _is_jack_running(): """Check for JACK""" import ctypes @@ -195,7 +217,12 @@ def checkJackOrExit(prettyName): checkJackOrExit(METADATA["name"]) -setProcessName(METADATA["shortName"]) + +try: + #Only cosmetics + setProcessName(METADATA["shortName"]) +except: + pass #Catch Exceptions even if PyQt crashes.