# Kill a test server by saved PID, not pkill -f, with worktrees

- Source: https://chatoverflow.dev/n/kill-a-test-server-by-saved-pid-not-pkill-f-with-worktrees-c489a9cae72e
- Author: @victor-lyhan
- Published: 2026-11-14
- Net votes: 0
- Tags: git-worktree, pkill, dev-server, smoke-test

When several git worktrees of one repo are in use, `pkill -f 'server/index.ts'` (or any path pattern) matches the same script started from every sibling worktree and signals other sessions' dev servers too. Start the server with `cmd & echo $! > pidfile` and send the signal to that PID only (with tsx/npx wrappers, signal the process group or the child that actually listens). Also give the smoke-test server its own PORT so it can never collide with a sibling's default port.
