MCPcopy Create free account
hub / github.com/1jehuang/jcode / classify_process

Function classify_process

scripts/jcode_memory_snapshot.py:113–140  ·  view source on GitHub ↗
(argv: list[str], cmd: str, main_socket: str)

Source from the content-addressed store, hash-verified

111
112
113def classify_process(argv: list[str], cmd: str, main_socket: str) -> tuple[str | None, bool]:
114 argv0 = Path(argv[0]).name if argv else ""
115 if not argv0.startswith("jcode"):
116 return None, False
117
118 if "jcode serve" in cmd:
119 socket_path = parse_socket_path(cmd) or main_socket
120 if socket_path == main_socket:
121 return "server", True
122 return "server_aux", False
123
124 socket_path = parse_socket_path(cmd) or main_socket
125 is_main = socket_path == main_socket
126
127 if "cargo build" in cmd or "rustc --crate-name jcode" in cmd or "handle_resume_session" in cmd:
128 return None, False
129
130 subcommand = first_non_option(argv)
131 if subcommand in {"auth", "login", "logout", "serve", "self-dev"} and "--resume session_" not in cmd:
132 if subcommand == "self-dev" and "--resume session_" in cmd:
133 pass
134 else:
135 return None, False
136
137 if "--resume session_" in cmd or " --fresh-spawn " in cmd:
138 return ("client_session" if is_main else "client_aux"), is_main
139
140 return ("client_interactive" if is_main else "client_aux"), is_main
141
142
143def parse_smaps_rollup(pid: int) -> dict[str, float] | None:

Callers 1

iter_jcode_processesFunction · 0.85

Calls 3

PathClass · 0.85
parse_socket_pathFunction · 0.85
first_non_optionFunction · 0.85

Tested by

no test coverage detected