forked from commaai/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Custom setproctitle (commaai#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 <[email protected]> Co-authored-by: Adeeb Shihadeh <[email protected]> * revert that for now * use last 15 * fix * use name * update those * and modeld * rm --------- Co-authored-by: schlimeszn <[email protected]> Co-authored-by: reddyn12 <[email protected]> Co-authored-by: Comma Device <[email protected]>
- Loading branch information
1 parent
81dc33e
commit 83ac80c
Showing
9 changed files
with
61 additions
and
137 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 "" |
Large diffs are not rendered by default.
Oops, something went wrong.
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
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