Skip to content

Commit 726f746

Browse files
sjarmakclaude
andcommitted
Fix OH launcher crash when pkill is missing in container
The generated oh_launcher.py called subprocess.run(['pkill', ...]) which raises FileNotFoundError on images without procps installed. Guard with shutil.which() and fall back to os.system() kill pipeline. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent fb1e9ec commit 726f746

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

agents/harnesses/openhands/agent.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,12 @@ def create_run_agent_commands(self, instruction: str):
258258
"log.close()",
259259
"rc = proc.wait()",
260260
# Kill known OpenHands daemons that outlive the main process
261-
"for pat in ['jupyter-kernelgateway', 'ipykernel_launcher', 'openhands.runtime.action_execution_server', 'tmux']:",
262-
" subprocess.run(['pkill', '-f', pat], capture_output=True)",
261+
"import shutil",
262+
"if shutil.which('pkill'):",
263+
" for pat in ['jupyter-kernelgateway', 'ipykernel_launcher', 'openhands.runtime.action_execution_server', 'tmux']:",
264+
" subprocess.run(['pkill', '-f', pat], capture_output=True)",
265+
"else:",
266+
" os.system(\"kill $(ps aux | grep -E 'jupyter-kernelgateway|ipykernel_launcher|action_execution_server|tmux' | grep -v grep | awk '{print $2}') 2>/dev/null\")",
263267
"sys.exit(rc)",
264268
])
265269

0 commit comments

Comments
 (0)