from pathlib import Path import os,json busy=[] for p in Path('/proc').glob('[0-9]*'): try: if int(p.name)==os.getpid():continue comm=(p/'comm').read_text().strip() if not any(x in comm for x in ['node','python','bash']):continue args=(p/'cmdline').read_bytes().split(b'\0') if (comm.startswith('node') and b'--test' in args) or any(x.rsplit(b'/',1)[-1] in (b'run-mutants.py',b'gate-run.sh') for x in args): busy.append(dict(pid=int(p.name),cwd=str((p/'cwd').resolve()),name=comm)) except (PermissionError,FileNotFoundError,ProcessLookupError):pass print('BUSY_CHECK',json.dumps(busy)) raise SystemExit(bool(busy))