Ctrl+C exits 1 or 130 depending on whether the command was pollable #263
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The same Ctrl+C reports two different exit codes depending on whether the command future happened to be pollable when the signal arrived.
Measured on
b2ebe8a(the head of #261), withXDG_CONFIG_HOMEredirected to a scratch dir and no live forge:The first is
fj auth login --with-token, parked in a synchronous stdin read that the graceful select cannot cancel, sointerrupt::force_exitends it with 130. The second is the OIDC loopback wait, which is ordinary async, socli::run's select wins and the interrupt surfaces as an ordinaryanyhowerror thatmainmaps to 1.Why this is worth fixing rather than documenting
std::process::exit, so destructors are skipped. That is the mechanism behind the non-atomic token store write fixed in #261, so the difference is not only cosmetic.Why it was not fixed in #261
Giving the graceful path the same code changes the contract of every interrupted command, not just the wedged ones, and anything currently keying on 1 would see 130 instead. That is a deliberate decision about the CLI's interface, and #261 is a data-loss fix; it did not seem right to change the exit code of every Ctrl+C while fixing a credential write.
What the fix looks like
Have the graceful interrupt return 130 as well, so the code means "interrupted" regardless of which mechanism ended the process. That is a change in
cli::run/main's error mapping rather than ininterrupt, since the backstop is already correct.