Skip to content

[Bug]: Terminal tool hangs indefinitely when using setsid + disown pattern to launch background services #8340

@vandaik-sudo

Description

@vandaik-sudo

Bug Description

Summary

When the agent executes a long-running service startup command that combines
setsid, background operator (&), and disown — for example to restart a
FastAPI/uvicorn backend — the entire conversation freezes indefinitely and
never returns a result. This effectively deadlocks the session.

Environment

  • Hermes version: latest (gateway mode, Telegram interface)
  • Terminal backend: local
  • OS: Debian/Ubuntu Linux (root user)
  • Shell: bash
  • Provider/Model: GitHub Copilot / claude-sonnet-4.6 ......

Steps to Reproduce

Ask the agent to restart a uvicorn backend service. The agent generates and
executes a command like:

cd /root/baize && \
  source venv/bin/activate && \
  setsid python -m uvicorn backend.main:app \
    --host 0.0.0.0 --port 5566 \
    > /tmp/baize_backend.log 2>&1 < /dev/null & disown

This command pattern is also present in the agent's own MEMORY as the
recommended way to start the service, so it is reliably reproduced every time
the agent decides to restart the backend.

Expected Behavior

The terminal tool should return immediately (exit 0) after spawning the
detached background process, and the conversation should continue normally.

Actual Behavior

The terminal tool call never returns. The conversation is permanently stuck —
no response is ever delivered to the user. The agent session must be abandoned
and a new one started. The backend process itself may or may not actually start
(it does start in the background), but Hermes never acknowledges completion.

Affected Component

CLI (interactive chat)

Messaging Platform (if gateway-related)

No response

Operating System

Ubuntu 24.04

Python Version

3.12.3

Hermes Version

Hermes Agent v0.8.0 (2026.4.8)

Relevant Logs / Traceback

Root Cause Analysis (optional)

No response

Proposed Fix (optional)

No response

Are you willing to submit a PR for this?

  • I'd like to fix this myself and submit a PR

Metadata

Metadata

Assignees

No one assigned

    Labels

    type/bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions