Repository navigation
Conversation
After the user initiates a shutdown with SIGINT/SIGTERM/SIGHUP, the per-command 'exited with code ...' lines are noise: the shutdown was requested, so of course the commands exited. Worse, when the shell reclaims the terminal before teardown finishes, those late lines land on the fresh prompt and visually corrupt it. KillOnSignal now exposes an onSignal hook; LogExit takes an isShuttingDown predicate wired to it in lib/index.ts. Exit codes and shutdown behavior are unchanged — only the log lines are skipped, and only for closes that happen after the signal was caught. Fixes open-cli-tools#255
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.
Fixes #255
Problem
After pressing Ctrl-C, every command logs
exited with code SIGINT. When the shell reclaims the terminal before teardown finishes (e.g. the npm/yarn wrapper exits first), those late lines land on the fresh prompt and visually corrupt it — the prompt only reappears after another Ctrl-C or any command that writes to stdout. All reporters describe the same recovery pattern, which points at late output clobbering the prompt rather than a dead terminal.Fix
Once
KillOnSignalcatches SIGINT/SIGTERM/SIGHUP, the per-command exit log lines are noise — the user requested the shutdown, so the exits are expected (the codebase already remaps post-SIGINT exits to code 0 for the same reason). This change skips just those log lines:KillOnSignalaccepts an optionalonSignalcallback, invoked synchronously when a signal is caught, before commands are killed.LogExitaccepts an optionalisShuttingDownpredicate; close events arriving while it returns true are not logged.lib/index.tswires the two together with a shared flag. Both new options are optional, so the public API stays backwards compatible.Exit codes, kill behavior, and shutdown ordering are unchanged — closes that happen before the signal are still logged, and normal (non-signal) exits log exactly as before.
Verification
LogExitskips logging while shutting down / logs when not;KillOnSignalinvokesonSignal.bin/index.spec.ts: the SIGINT test now asserts exit code 0 and the absence of the exit log line.tsc --noEmitclean.exited with code SIGINTlines); normalecho/exit 3run still logs exits and returns code 1.