Skip to content

Fix UtilExec: remove premature Result check that breaks output capture#40327

Merged
benhillis merged 1 commit intofeature/wsl-for-appsfrom
copilot/fix-h1-utilexec-dead-code
Apr 27, 2026
Merged

Fix UtilExec: remove premature Result check that breaks output capture#40327
benhillis merged 1 commit intofeature/wsl-for-appsfrom
copilot/fix-h1-utilexec-dead-code

Conversation

@benhillis
Copy link
Copy Markdown
Member

@benhillis benhillis commented Apr 25, 2026

On the feature branch, an if (Result < 0) { goto ErrorExit; } check was added inside the fgets loop in UtilExec. Since Result is initialized to -1 and not set until after the loop (via pclose()), this fires on the first iteration, making output capture dead code.

This bug does not exist on master — it was introduced on the feature branch.

Fix: Remove the erroneous 4-line check.

Result was initialized to -1 and checked (Result < 0) inside the fgets
loop before ever being set to a success value. This caused the first
iteration to immediately goto ErrorExit, making all output capture
dead code. The Result variable is properly set after the loop completes
via pclose(), so the in-loop check was erroneous.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 25, 2026 21:03
@benhillis benhillis requested a review from a team as a code owner April 25, 2026 21:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a regression in UtilExecCommandLine() where an in-loop Result < 0 check caused an early goto ErrorExit, making normal output capture effectively unreachable (since Result is initialized to -1 and only set after the read loop).

Changes:

  • Remove the erroneous Result < 0 / goto ErrorExit block inside the fgets() loop so output can be accumulated as intended.

@benhillis benhillis merged commit 5abfcdd into feature/wsl-for-apps Apr 27, 2026
12 checks passed
@benhillis benhillis deleted the copilot/fix-h1-utilexec-dead-code branch April 27, 2026 21:27
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.

4 participants