Skip to content

Fix start target's kill 0 trap killing the invoking process group under make -n - #63

Open
AmirF194 wants to merge 1 commit into
neo4j-labs:mainfrom
AmirF194:fix/57-makefile-trap-kill0
Open

Fix start target's kill 0 trap killing the invoking process group under make -n#63
AmirF194 wants to merge 1 commit into
neo4j-labs:mainfrom
AmirF194:fix/57-makefile-trap-kill0

Conversation

@AmirF194

@AmirF194 AmirF194 commented Sep 7, 2026

Copy link
Copy Markdown

Summary

  • The start target's trap 'kill 0' EXIT runs even under make -n, because GNU make always executes a recipe line that references $(MAKE). Under -n the two sub-makes finish instantly, wait returns, and the trap fires kill 0, SIGTERMing the whole process group, not just the recipe's own children. That's what kills VS Code: Makefile Tools runs make -n on folder open from inside the extension host's process group.
  • Your suggested kill $(jobs -p) fixes the dry-run crash, but on a real run it only reaches the two sub-make PIDs, not their own children (the actual uvicorn/npm processes). I checked: sending a plain SIGTERM straight to a running make dev-backend does not kill the sleep/server underneath it, since make doesn't forward the signal down. So that version leaves both dev servers orphaned after Ctrl-C.
  • Went with guarding the whole real body on $(MAKEFLAGS) instead (the same findstring n check the docs already use to detect dry-run elsewhere in the project). Under -n, start just echoes, like every other target does when it doesn't reference $(MAKE). The real-run trap/wait/kill 0 path is untouched, so Ctrl-C cleanup still works exactly as before.

Fixes #57.

Test plan

  • make -n start in a generated project used to send SIGTERM to the invoking process (matches your repro exactly), now exits 0. Added test_makefile_dry_run_does_not_kill_process_group, red on main, green on this branch.
  • Full existing test suite passes on 3.11 and 3.12, ruff clean. (3.11 has 22 pre-existing failures in test_routes_integration.py/test_wizard.py, unrelated to this file, same on main.)

…er make -n

The start target's `trap 'kill 0' EXIT` runs even under `make -n`, because
recipe lines referencing $(MAKE) always execute regardless of --dry-run. Under
-n the sub-makes finish instantly, wait returns, and the trap fires kill 0,
SIGTERMing the whole process group, not just the recipe's own children. This
is what crashes VS Code's Makefile Tools extension, which runs make -n on
folder open from inside its own process group.

Guard the real body on MAKEFLAGS instead of narrowing what the trap kills:
under a dry run the target now just echoes, matching every other target's
-n behavior, and the real-run trap/wait logic is untouched.

Fixes neo4j-labs#57.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generated Makefile trap 'kill 0' kills the parent process group under make -n — VS Code (Makefile Tools) crashes on folder open

1 participant