Skip to content

[tooling] anvil_fork.sh has no SIGINT/SIGTERM/EXIT trap — Ctrl-C leaves orphan anvil on 8545 #240

@obchain

Description

@obchain

Refs #52

File: scripts/anvil_fork.sh

Problem

Script spawns anvil but does not trap signals. On Ctrl-C or terminal close, parent bash dies; anvil keeps running holding port 8545. Next invocation fails with 'address already in use'. Operator must pkill anvil manually.

Fix

ANVIL_PID=""
cleanup() {
  if [[ -n "$ANVIL_PID" ]]; then
    kill -TERM "$ANVIL_PID" 2>/dev/null || true
    wait "$ANVIL_PID" 2>/dev/null || true
  fi
}
trap cleanup EXIT INT TERM

anvil ... &
ANVIL_PID=$!
wait "$ANVIL_PID"

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinglayer:devopsCI / deploy / infra / telemetrypr-reviewFindings from PR review processpriority:p1-coreCore MVP scopestatus:readyScoped and ready to pick up

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions