diff options
author | Devaev Maxim <[email protected]> | 2020-06-04 06:27:52 +0300 |
---|---|---|
committer | Devaev Maxim <[email protected]> | 2020-06-04 06:27:52 +0300 |
commit | 9cee98310deb851c4a5c36b1e593f032f8234c32 (patch) | |
tree | 907d908432c5ce43c729866d67a323daf35aa25e /kvmd/aioproc.py | |
parent | be9ce4e4ffa418ba64612efdabee116dd59a6f5d (diff) |
refactoring
Diffstat (limited to 'kvmd/aioproc.py')
-rw-r--r-- | kvmd/aioproc.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/kvmd/aioproc.py b/kvmd/aioproc.py index a778141d..4c503bca 100644 --- a/kvmd/aioproc.py +++ b/kvmd/aioproc.py @@ -27,6 +27,8 @@ import signal from typing import Tuple from typing import List +import setproctitle + # ===== async def run_process(cmd: List[str], err_to_null: bool=False) -> asyncio.subprocess.Process: # pylint: disable=no-member @@ -34,7 +36,7 @@ async def run_process(cmd: List[str], err_to_null: bool=False) -> asyncio.subpro *cmd, stdout=asyncio.subprocess.PIPE, stderr=(asyncio.subprocess.DEVNULL if err_to_null else asyncio.subprocess.STDOUT), - preexec_fn=preexec_ignore_sigint, + preexec_fn=ignore_sigint, )) @@ -44,5 +46,9 @@ async def read_process(cmd: List[str], err_to_null: bool=False) -> Tuple[asyncio return (proc, stdout.decode(errors="ignore").strip()) -def preexec_ignore_sigint() -> None: +def ignore_sigint() -> None: signal.signal(signal.SIGINT, signal.SIG_IGN) + + +def rename_process(suffix: str, prefix: str="kvmd") -> None: + setproctitle.setproctitle(f"{prefix}/{suffix}: {setproctitle.getproctitle()}") |