Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add process termination to stop button functionality #6862

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

neubig
Copy link
Contributor

@neubig neubig commented Feb 20, 2025

This PR adds process termination functionality to the stop button. When the stop button is clicked:

  1. The agent state is changed to STOPPED
  2. The runtime terminates all processes in its environment:
    • LocalRuntime: Uses ps and kill to manage local processes
    • DockerRuntime: Uses pkill inside the container
    • ModalRuntime: Uses sandbox termination
    • RemoteRuntime: Uses API calls

Each runtime handles process termination in a way appropriate to its environment, with graceful termination (SIGTERM) followed by force kill (SIGKILL) if needed.

Tested with:

  • Processes that handle SIGTERM gracefully
  • Processes that ignore SIGTERM
  • Nested processes (parent/child)
  • Multiple concurrent processes

Fixes #6848


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:411cfa9-nikolaik   --name openhands-app-411cfa9   docker.all-hands.dev/all-hands-ai/openhands:411cfa9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Stop button does not terminate background process
2 participants