Skip to content

install.sh spin() has no trap handler — Ctrl+C orphans background processes and leaks temp files #1020

@latenighthackathon

Description

@latenighthackathon

Description

install.sh has zero trap statements in the entire 550+ line script. The spin() function (line 185) backgrounds a command and polls it with a spinner animation, but if the user presses Ctrl+C during execution:

  1. The backgrounded process (npm install, docker build, git clone, etc.) continues running
  2. The temp file created by mktemp on line 188 is never cleaned up
  3. Any partially-written state (node_modules, Docker layers, cloned repos) is left behind

What happens: Ctrl+C during installation leaves orphaned processes running and temp files in /tmp.

What should happen: The script should register a cleanup trap that kills backgrounded processes and removes temp files on SIGINT/SIGTERM.

Reproduction Steps

  1. Run the installer: curl -fsSL https://www.nvidia.com/nemoclaw.sh | bash
  2. During any spinner step (e.g., "Preparing OpenClaw package", "Installing dependencies"), press Ctrl+C
  3. Check for orphaned processes:
    ps aux | grep -E "npm install|docker build|git clone"
  4. Check for leaked temp files:
    ls /tmp/tmp.*

Environment

  • Code review of main branch (commit HEAD as of 2026-03-26)
  • Affected file: install.sh — entire file

Logs

No trap in the entire script:

$ grep -n 'trap ' install.sh
# (no output)

spin() function — backgrounds command, no cleanup (lines 185–212):

spin() {
  # ...
  local log
  log=$(mktemp)              # temp file created
  "$@" >"$log" 2>&1 &        # command backgrounded
  local pid=$! i=0

  while kill -0 "$pid" 2>/dev/null; do
    printf "\r  %s  %s" "${frames[$((i++ % 10))]}" "$msg"
    sleep 0.08
  done

  # ... status check ...
  rm -f "$log"               # only cleaned up on normal exit
  return $status
}

Expected pattern:

_cleanup_pids=()
_cleanup_files=()

cleanup() {
  for pid in "${_cleanup_pids[@]}"; do
    kill "$pid" 2>/dev/null
  done
  for f in "${_cleanup_files[@]}"; do
    rm -f "$f"
  done
}
trap cleanup EXIT SIGINT SIGTERM

spin() {
  local log
  log=$(mktemp)
  _cleanup_files+=("$log")
  "$@" >"$log" 2>&1 &
  local pid=$!
  _cleanup_pids+=("$pid")
  # ...
}

Checklist

  • I confirmed this bug is reproducible
  • I searched existing issues and this is not a duplicate

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