-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 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 <[email protected]> Co-authored-by: Adeeb Shihadeh <[email protected]>
- Loading branch information
1 parent
0bdab82
commit e76e8bf
Showing
7 changed files
with
40 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters