Custom setproctitle (#32667)
* 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>
old-commit-hash: 3365ed5eff
testing-closet^2
parent
50dd024081
commit
afea57ae2a
8 changed files with 42 additions and 16 deletions
@ -0,0 +1,8 @@ |
|||||||
|
from openpilot.common.threadname import setthreadname, getthreadname, LINUX |
||||||
|
|
||||||
|
class TestThreadName: |
||||||
|
def test_set_get_threadname(self): |
||||||
|
if LINUX: |
||||||
|
name = 'TESTING' |
||||||
|
setthreadname(name) |
||||||
|
assert name == getthreadname() |
@ -0,0 +1,19 @@ |
|||||||
|
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 "" |
@ -1,3 +1,3 @@ |
|||||||
version https://git-lfs.github.com/spec/v1 |
version https://git-lfs.github.com/spec/v1 |
||||||
oid sha256:0d9f6a97cc9f69ab14aaa50e64ee4bd0da11fa1b2fa8314d7b7ec4a380fe9e8f |
oid sha256:e3c0ed6349feb2a75a11fab5939e40b757c735855c617b9147de3d614e0b6c50 |
||||||
size 618404 |
size 603428 |
||||||
|
Loading…
Reference in new issue