Skip to content

killProcess maybe doesn't work? #338

@pandemicsyn

Description

@pandemicsyn

Noticed that while the sdk reports processes as killed it seems like we had process running to completion. even after switching from term to kill signal. Poking around the sdk with the help of the 🤖 found that:

When calling killProcess() on a background process started via startProcess(), the API returns success: true but the actual process continues running.

The issue is in packages/sandbox-container/src/session.ts. When a background process is started, it runs inside a bash subshell:

{
  # command runs here
} < /dev/null > "$sp" 2> "$ep" & CMD_PID=$!
echo "$CMD_PID" > ${pidFile}

The $CMD_PID stored is the subshell PID, not the actual command PID. When killCommand() sends SIGTERM to this PID:

  1. The subshell receives SIGTERM
  2. Bash does NOT propagate signals to child processes by default
  3. The subshell terminates
  4. The actual command becomes an orphan process and keeps running

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions