Skip to content

[WSLC] Stdin work follow-up - #1597

Open
Soham Das (SohamDas2021) wants to merge 2 commits into
mainfrom
sohamdas2021-wslc-stdin-followup-estimate
Open

Soham Das (SohamDas2021) wants to merge 2 commits into
mainfrom
sohamdas2021-wslc-stdin-followup-estimate

Conversation

@SohamDas2021

@SohamDas2021 Soham Das (SohamDas2021) commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

Fixes the two correctness items left open when #1564 was approved.

CLI: stdin is closed only after the command is known to be stopped. If reading wxc-exec's stdin fails while a WSLc command runs, the executor stops the container and now waits for the command to exit before closing the command's stdin. Previously the result of the stop was ignored, so a command that was still running could read the cut-short input as complete, for example cat > staged && mv staged live publishing a truncated file.

  • If the stop can't be confirmed, the command's stdin stays open until the container is torn down. The run fails with a message saying the command could not be confirmed stopped.
  • A run with no timeout no longer hangs in that case.
  • When a run times out, stdin is no longer closed before the command is known to be gone, so a command that ignores SIGTERM can't read early end-of-file either.

.NET: waits stay responsive while a finished process is cleaned up. On WSLc, a command that exits leaving a lot of stdin unread is reported about a minute late, and MxcProcess spends that time in cleanup. During it:

  • cancelling WaitAsync now returns at once, and a later wait returns the result;
  • Kill returns at once without doing anything;
  • Dispose returns at once, and the process is released when cleanup finishes, before the wait returns;
  • Warnings returns the warnings from before cleanup started, and OutputMetadata is null until cleanup finishes.

Before, all of these waited for the cleanup; #1564 fixed only Kill. The native API is unchanged.

🔗 References

Follow-up to #1564 (review findings 2 and 4). Finding 6 only concerned the #1564 description, which is corrected there.

🔍 Validation

Windows with WSL 3.0.4 and WSLc SDK 3.0.3 (vendored; the MxcDependencies feed returned 401).

Command Result
cargo fmt --all -- --check Passed
cargo clippy --workspace --all-targets -- -D warnings Passed
cargo clippy -p mxc-sdk -p mxc_ffi --features wslc --all-targets -- -D warnings Passed
cargo test -p mxc-sdk --features wslc --lib Passed: 2835 passed, 0 failed
.NET suite (Microsoft.Mxc.Sdk.Tests, built with -p:MxcWithWslc=true) Passed: 373 passed, 0 failed, 49 skipped (live-host tests)
Same, with MXC_ENABLE_WSLC_TESTS=1, class MxcContainerWslcE2ETests Passed: 11/11
tests\scripts\run_wslc_all_tests.ps1 -Debug -SkipSetup Passed: create-and-run 49/49 (9 stdin cases), container lifecycle 139/139
Node wslc-e2e.test.js with MXC_ENABLE_WSLC_TESTS=1 Passed: 8/8

New tests:

  • Live .NET: cancelling WaitAsync, and calling Warnings and Dispose, while a wait is in the late-exit cleanup. Both tests fail without the MxcProcess change and pass with it. They are in the class the scheduled WSLc validation already runs.
  • Rust unit: a forwarding failure whose stop can't be confirmed keeps the command's stdin open until teardown, and the run's wait ends on either the process exiting or the forwarding failure.

Not covered live: a failed or unconfirmed container stop, which can't be triggered on a real host; the unit tests cover it. The Node SDK unit tests were not run, since nothing in the Node SDK changed.

✅ Checklist

📋 Issue Type

  • Bug fix
  • Feature
  • Task
Microsoft Reviewers: Open in CodeFlow

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 21:33
@SohamDas2021
Soham Das (SohamDas2021) requested a review from a team as a code owner October 27, 2026 21:33

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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

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.

🟡 Changes recommended

Unresolved stdin error paths, a V1 disposal compatibility break, timeout misreporting, and regression-test gaps prevent approval.

6 open issues

Review effort: Balanced

Comment on lines +924 to +926
if (_isFinishing)
{
return;
Comment on lines +1454 to +1455
drop(started);
drop(ended.open_stdin);
Comment thread src/mxc-sdk/src/backends/wslc/common/wsl_container_runner.rs Outdated
Comment thread sdk/dotnet/Microsoft.Mxc.Sdk.Tests/V1/MxcContainerWslcE2ETests.cs Outdated
Comment thread sdk/dotnet/Microsoft.Mxc.Sdk.Tests/V1/MxcContainerWslcE2ETests.cs Outdated
Comment thread sdk/dotnet/Microsoft.Mxc.Sdk/V1/MxcProcess.cs
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings October 27, 2026 23:16

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.

🟡 Changes recommended

Forwarding-setup failures can still deliver premature EOF, and timeout ordering lacks a functional regression that detects it.

3 open issues
1 previously missed issue

In code that hasn't changed since last review

Medium severity Add regression for premature stdin EOF after timeout

src/​mxc-sdk/​src/​backends/​wslc/​common/​wsl_container_runner.rs:714

[P2] The timeout stdin-close ordering fix lacks a regression through the CLI/backend flow; the existing cat timeout case in tests/scripts/run_wslc_all_tests.ps1:628-637 checks only the timeout result and would still pass with premature EOF. Extend that scheduled suite with a command that ignores SIGTERM and writes a persistent marker only after EOF, keeping host stdin open through the timeout. Assert that the run times out without writing the marker, so restoring the unconditional close_stdin() fails the test.

4 resolved since last review

Review effort: Balanced

Comment on lines +1399 to +1401
Err((error, pipe)) => {
started.quiesce(logger);
drop(pipe);

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.

2 participants