Fix start target's kill 0 trap killing the invoking process group under make -n - #63
Open
AmirF194 wants to merge 1 commit into
Open
Fix start target's kill 0 trap killing the invoking process group under make -n#63AmirF194 wants to merge 1 commit into
AmirF194 wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
starttarget'strap 'kill 0' EXITruns even undermake -n, because GNU make always executes a recipe line that references$(MAKE). Under-nthe two sub-makes finish instantly,waitreturns, and the trap fireskill 0, SIGTERMing the whole process group, not just the recipe's own children. That's what kills VS Code: Makefile Tools runsmake -non folder open from inside the extension host's process group.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 runningmake dev-backenddoes not kill thesleep/server underneath it, since make doesn't forward the signal down. So that version leaves both dev servers orphaned after Ctrl-C.$(MAKEFLAGS)instead (the samefindstring ncheck the docs already use to detect dry-run elsewhere in the project). Under-n,startjust echoes, like every other target does when it doesn't reference$(MAKE). The real-run trap/wait/kill 0path is untouched, so Ctrl-C cleanup still works exactly as before.Fixes #57.
Test plan
make -n startin a generated project used to send SIGTERM to the invoking process (matches your repro exactly), now exits 0. Addedtest_makefile_dry_run_does_not_kill_process_group, red on main, green on this branch.test_routes_integration.py/test_wizard.py, unrelated to this file, same on main.)