Skip to content

Delegate Ctrl+C handling for shims#513

Merged
chriskrycho merged 1 commit intovolta-cli:masterfrom
charlespierce:better_ctrlc_handling
Aug 2, 2019
Merged

Delegate Ctrl+C handling for shims#513
chriskrycho merged 1 commit intovolta-cli:masterfrom
charlespierce:better_ctrlc_handling

Conversation

@charlespierce
Copy link
Contributor

Closes #500

Info

Currently the Ctrl+C SIGINT signal is being sent to both the Volta process and the shimmed child process simultaneously. This means that if a shim waits after receiving the SIGINT signal (as in the repro example in #500), Volta will still exit immediately and not wait for the shim.

Changes

  • Used the ctrlc crate to set a handler for Ctrl+C in the shim executable.
  • Handler uses a flag to determine if control has been passed to the shim or not.
    • If it has, the handler does nothing and lets the child process control the flow of the application.
    • If it hasn't, then we are still doing Volta work (perhaps downloading a version of Node), so it exits immediately (the default behavior).
  • Added a call to set the flag immediately before running the shim process.

Tested

  • Confirmed that the reproduction case in the issue is handled correctly, the process waits for Node to exit before returning control to the user.
  • Verified that interrupting the automatic download of a tool still correctly interrupts immediately.
  • Tested on both Mac & Windows to ensure that the behavior is accurate cross-platform.

@chriskrycho chriskrycho self-requested a review August 2, 2019 22:19
@chriskrycho chriskrycho merged commit 5c49772 into volta-cli:master Aug 2, 2019
@charlespierce charlespierce deleted the better_ctrlc_handling branch August 30, 2019 16:33
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.

Volta ctrl-c exits too early

2 participants

Comments