Update dsc.exe to have single process exit point - #1693
Open
Steve Lee (SteveL-MSFT) wants to merge 4 commits into
Open
Update dsc.exe to have single process exit point#1693Steve Lee (SteveL-MSFT) wants to merge 4 commits into
dsc.exe to have single process exit point#1693Steve Lee (SteveL-MSFT) wants to merge 4 commits into
Conversation
Steve Lee (SteveL-MSFT)
requested review from
Mikey Lombardi (He/Him) (michaeltlombardi) and
Tess Gauthier (tgauth)
and
a lite review from Copilot
August 26, 2026 03:33
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors the dsc CLI to avoid calling std::process::exit() throughout the codebase, instead propagating std::process::ExitCode via Result so the process exits through a single return path (improving Windows code coverage collection).
Changes:
- Replaces many
exit(<code>)calls withResult<_, ExitCode>propagation across CLI helper functions and subcommand handlers. - Updates CLI exit code constants to
u8to align withExitCode::from(u8). - Adjusts output and input utilities (
write_object,get_input, config root initialization) to returnResultrather than terminating the process.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| dsc/src/util.rs | Converts exit-code constants to u8 and updates utility helpers to return Result<_, ExitCode> instead of exiting. |
| dsc/src/subcommand.rs | Updates subcommand entrypoints/helpers to return Result<(), ExitCode> and propagate failures upward. |
| dsc/src/resource_command.rs | Changes resource command handlers to return Result<(), ExitCode> and replace exit() with propagated ExitCode. |
| dsc/src/main.rs | Makes main() return ExitCode and routes subcommands through dsc_main() -> Result<(), ExitCode>. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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.
PR Summary
There's a known issue using
std::process::exit()on Windows that prevents code coverage data from being collected. Fix is to switch to havingmain()returnExitCodewhich accomplishes the same thing. The previous code indsc.exehad many calls toexit()which is not ideal since there are now multiple ways for the process to exit. Changed many functions in the exe to return aResult<>instead which wraps the exit code it would have returned so now there's a single place where that gets returned.ExitCode::from()takes a u8 so changed the consts to u8 instead of i32.