fix(cli): set SPT_NOENV only on Linux
SPT_NOENV only keeps the title out of /proc/PID/environ on Linux. On macOS it confines the title to the argv area, where setproctitle drops the last byte, and its import-time getproctitle() then fails to decode a command line ending in a multibyte character, so every such CLI call crashed. Fixes #6231
This commit is contained in:
1 parent
12e869d047
commit
a148eabc9f
2 files changed
+29
-4
No files matched your search
@@ -4,6 +4,7 @@ from __future__ import annotations
|
||||
|
||||
import hashlib
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
from typing import Final
|
||||
|
||||
@@ -11,9 +12,8 @@ _ROLES: Final = {"agent", "gateway", "webui"}
|
||||
|
||||
|
||||
def _set_process_title(title: str) -> None:
|
||||
# Process titles are short; do not trade Linux /proc environment visibility for
|
||||
# extra title storage. setproctitle reads this switch when it is imported.
|
||||
os.environ.setdefault("SPT_NOENV", "1")
|
||||
if sys.platform == "linux":
|
||||
os.environ.setdefault("SPT_NOENV", "1")
|
||||
from setproctitle import setproctitle
|
||||
|
||||
setproctitle(title)
|
||||
|
||||
Reference in new issue
Block a user