Skip to content

coreutils: return ExitCode from main instead of calling exit - #15535

Open
sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:multicall-return-exitcode
Open

sylvestre wants to merge 1 commit into
uutils:mainfrom
sylvestre:multicall-return-exitcode

Conversation

@sylvestre

Copy link
Copy Markdown
Contributor

closes: #15522

Copilot AI balanced review requested due to automatic review settings October 19, 2026 20:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Warning

Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.

Copilot review overview

2 open issues
What changed in this PR

Updates the coreutils multicall binary to return std::process::ExitCode from main instead of calling process::exit in most paths, aligning with Rust idioms and improving destructor/drop behavior.

Changes:

  • Change main signature to fn main() -> ExitCode and replace many exit(0/1) calls with return ExitCode::{SUCCESS,FAILURE}.
  • Preserve behavior for non-u8 exit codes by falling back to process::exit(code) when needed.
File Description
src/​bin/​coreutils.rs Switches main to return ExitCode and replaces most direct exit() calls with returned exit codes.

Review effort: Lite

Comment thread src/bin/coreutils.rs
Comment on lines +58 to +61
let Some(binary_as_util) = validation::name(&binary) else {
usage(&utils, "<unknown binary name>");
exit(0);
});
return ExitCode::SUCCESS;
};
Comment thread src/bin/coreutils.rs
Comment on lines +124 to +127
let code = uumain(vec![util_os].into_iter().chain(args));
// Return instead of exiting so that locals are dropped; exit codes
// that don't fit in a u8 (Windows) still need process::exit.
return u8::try_from(code).map_or_else(|_| exit(code), ExitCode::from);
Comment thread src/bin/coreutils.rs
@@ -120,12 +121,15 @@ fn main() {
// Could be something like:
// #[cfg(not(feature = "only_english"))]
validation::setup_localization_or_exit(util);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it intentional that this exit is left untouched?

This branch has not been deployed

No deployments
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.

valgrind memory leaks in cat, pr, etc

3 participants