mirror of
https://github.com/sunnypilot/sunnypilot.git
synced 2026-02-19 01:53:57 +08:00
* add custom setproctitle * add test * Update poetry.lock * fix lint * support only Linux * test only Linux * final lint * Update test_setproctitle.py * Update setproctitle.py * convert to threadnames * delete proctitles * Check str len and use PR_GET_NAME * fix poetry.lock * lint fix * Update common/threadname.py --------- Co-authored-by: reddyn12 <nikhilr.ssm@gmail.com> Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
20 lines
415 B
Python
20 lines
415 B
Python
import ctypes
|
|
import os
|
|
|
|
LINUX = os.name == 'posix' and os.uname().sysname == 'Linux'
|
|
|
|
if LINUX:
|
|
libc = ctypes.CDLL('libc.so.6')
|
|
|
|
def setthreadname(name: str) -> None:
|
|
if LINUX:
|
|
name = name[:15] + '\0'
|
|
libc.prctl(15, str.encode(name), 0, 0, 0)
|
|
|
|
def getthreadname() -> str:
|
|
if LINUX:
|
|
name = ctypes.create_string_buffer(16)
|
|
libc.prctl(16, name)
|
|
return name.value.decode('utf-8')
|
|
return ""
|