Skip to content

[WSLC] Give spawn a writable stdin and remove the WithStdin APIs - #1762

Merged
Soham Das (SohamDas2021) merged 4 commits into
mainfrom
sohamdas2021-wslc-stdin-spawn
Nov 14, 2026
Merged

Soham Das (SohamDas2021) merged 4 commits into
mainfrom
sohamdas2021-wslc-stdin-spawn

Conversation

@SohamDas2021

@SohamDas2021 Soham Das (SohamDas2021) commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

📖 Description

On WSLC, spawn and spawn_in_container started the command with stdin already at end-of-file, unlike the other backends with piped stdio. To give a WSLC command input, callers had to use separate WithStdin methods.

WSLC's ordinary spawn methods now return a writable stdin in all three SDKs, and the WithStdin methods are removed.

  • Spawn: spawn and spawn_in_container in Rust, Spawn and SpawnInContainer in .NET, and spawn and spawnInContainer in Node, plus their V1.Dev JSON forms, give a WSLC command a writable stdin. Closing it, or waiting without taking it, gives the command end-of-file.
  • Run-to-completion is unchanged: run and run_in_container, and their .NET, Node and V1.Dev forms, still start a WSLC command with stdin at end-of-file. The .NET and Node container run helpers now use a new native entry point, mxc_exec_state_aware_for_run_json, rather than the spawn entry point.
  • Removed, never released: spawn_with_stdin and spawn_in_container_with_stdin (Rust), SpawnWithStdin(Async) and SpawnInContainerWithStdin(Async) (.NET), spawnWithStdin and spawnInContainerWithStdin (Node), and the native mxc_spawn_with_stdin_json and mxc_exec_state_aware_with_stdin_json. They were added in [WSLC] (1/2) Forward host stdin to state-aware exec #1562 and [WSLC] (2/2) Forward host stdin to create-and-run execution #1564 and only ever appeared under [Unreleased].
  • Other backends are unaffected. Only the WSLC backend reads the stdin choice, and MicroVM gets the same settings as before. In .NET, Wait closes a stdin the caller never took only for WSLC processes.

Breaking change: v1.0.1 documented that WSLC gives a command no stdin, so a WSLC command started by spawn or spawn_in_container read end-of-file at once. Now a command that reads stdin waits until the caller closes stdin or waits for the process, so a caller that reads all output before waiting must close stdin first. A timeout or kill in an existing container changes too; see Limitation. This changes documented V1 behavior in place instead of adding a V2 API. Before merge, it still needs a V1 exception in versioning.md and a breaking-change mark on the changelog entries.

Limitation: killing a still-running WSLC spawn_in_container command, or reaching its timeout, deletes its container about a minute later, because MXC does not signal a WSLC process that has stdin. This is documented in the WSLC guide, the API references and the changelogs. Separately, and before this change, on WSL 3.0.5 WslcSignalProcess(SIGKILL) fails with 0x80070032 even for a command without stdin, so a timed-out run_in_container loses its container too. A follow-up issue will cover both.

No spec: this makes WSLC's existing spawn methods behave like the other backends and removes methods that never shipped. There is no schema or MXC request JSON change.

🔗 References

Refs #1258

Follows #1562 and #1564, which added the WithStdin methods this PR replaces.

Follow-up for the WSLC kill limitation: issue to be filed.

🔍 Validation

PR CI passes on 5ddeed829.

PR CI doesn't run the WSLC tests, so they ran locally on 5ddeed829, on Windows build 26300 with WSL 3.0.5. They used alpine:latest from the image store and native files built from src/ with cargo build -p mxc-sdk --bin wxc-wslc-daemon --features wslc and cargo build -p mxc_ffi --features "dotnetsdk wslc test-support" (both passed).

  • Rust, from src/: cargo test -p mxc-sdk --features wslc --test streaming_wslc -- --ignored --test-threads=1: 3/3 passed
  • .NET net8.0, built with the .NET 9 MSBuild.dll and -p:TargetFramework=net8.0 -p:TargetFrameworks=net8.0 -p:MxcWithWslc=true -p:MxcPrebuiltNativeDir=<native files> -p:MxcTestPrebuiltNativeLibrary=<native files>\mxc_ffi.dll, because .NET SDK 10 isn't installed on this host. With MXC_ENABLE_WSLC_TESTS=1, Microsoft.Mxc.Sdk.Tests.exe -class *.MxcContainerWslcE2ETests -class *.MxcLifecycleWslcE2ETests -parallelMode none: 20/20 passed, none skipped
  • Node, after npm run build in sdk/node/, then npm ci and npm run build in sdk/node/tests/integration/, run there with MXC_ENABLE_WSLC_TESTS=1 and MXC_FFI_DIR set to the native files:
    • node --test dist/wslc-e2e.test.js: 9/9 passed
    • node --test dist/wslc-state-aware.test.js: 2/2 passed

The WSLC tests cover:

  • writable stdin and byte-exact forwarding for both spawn methods
  • stdin being a pipe, and end-of-file when stdin is closed or when waiting without taking it
  • closing stdin, reading all output, then waiting
  • run and run_in_container seeing /dev/null as stdin, in Rust and in the .NET and Node typed and V1.Dev run helpers
  • a killed command never acting on input closed after the kill

Scheduled Validation Tests now build the Rust WSLC tests into the Windows SDK test bundle and run them in the WSLC lane. Building the bundle fails if a required WSLC stdin test is missing, and the lane fails if one is skipped or fails.

Not run: the Windows SDK test bundle build (needs .NET SDK 10), Scheduled Validation Tests on this branch, the WSLC tests on net10.0, nvx_e2e (needs a MicroVM host), and the tests/scripts host suites.

✅ Checklist

  • Signed the Contributor License Agreement
  • Linked to an issue
  • For features or changes requiring a spec: linked the issue with maintainer-applied feature-accepted
  • For implementation: linked the required approved and merged design/API spec, or explained why no spec is required
  • Feature issue remains open unless this PR completes all agreed implementation, validation, and documentation
  • Updated documentation (if applicable)
  • Updated Copilot instructions (if build, architecture, or conventions changed)
  • If this PR changes Cargo.lock, the dependency-feed-check check passes (see pull request builds)

📋 Issue Type

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

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@SohamDas2021
Soham Das (SohamDas2021) requested review from a team and a balanced review from Copilot November 13, 2026 07:09
@SohamDas2021
Soham Das (SohamDas2021) requested a review from a team as a code owner November 13, 2026 07:09
@azure-pipelines

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

@SohamDas2021 Soham Das (SohamDas2021) changed the title [WSLC] Give V1 spawn a writable stdin and remove the WithStdin APIs [WSLC] Give spawn a writable stdin and remove the WithStdin APIs Nov 13, 2026

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

Existing V1 spawn APIs introduce breaking stdin and cancellation behavior that can hang callers or delete caller-owned containers, alongside missing WSLC regression coverage and overstated EOF guarantees.

4 open issues
What changed in this PR

This PR makes ordinary WSLC spawn operations expose writable stdin across the Rust, .NET, and Node SDKs, replacing the unreleased WithStdin APIs introduced for #1258.

Changes:

  • Enables writable stdin for ordinary spawn operations while preserving immediate end-of-file for run-to-completion helpers.
  • Updates native routing and SDK tests for input forwarding, stdin closure, and output collection.
  • Refreshes SDK references and backend guides, including the WSLC lifecycle cancellation limitation.
File Description
src/​mxc-sdk/​tests/​state_aware.rs Removes the retired lifecycle API signature check.
src/​mxc-sdk/​tests/​pty_options_api.rs Updates spawn signature coverage.
src/​mxc-sdk/​src/​sandbox.rs Consolidates lifecycle spawning and updates stdin documentation.
src/​mxc-sdk/​src/​lib.rs Separates spawn and run stdin behavior; removes redundant APIs.
src/​mxc-sdk/​src/​core/​mxc_engine/​state_aware.rs Scopes the stdin setting to WSLC lifecycle execution.
src/​mxc-sdk/​src/​core/​mxc_engine/​mod.rs Enables stdin for ordinary JSON spawning.
src/​mxc-sdk/​src/​core/​mxc_engine/​dispatch.rs Keeps stdin selection WSLC-specific and preserves MicroVM settings.
src/​mxc-sdk/​README.md Explains Rust spawn and run stdin behavior.
src/​ffi/​mxc_ffi/​src/​streaming.rs Removes the separate stdin spawn export.
src/​ffi/​mxc_ffi/​src/​state_aware.rs Adds the lifecycle run-helper export and updates validation tests.
sdk/​node/​tests/​unit/​v1-dev.test.ts Checks Dev lifecycle run routing.
sdk/​node/​tests/​unit/​streaming-binding.test.ts Tests ordinary stdin access and run-specific native routing.
sdk/​node/​tests/​unit/​state-aware.test.ts Updates lifecycle routing assertions.
sdk/​node/​tests/​unit/​inprocess-run.test.ts Removes retired API expectations.
sdk/​node/​tests/​integration/​wslc-state-aware.test.ts Tests lifecycle stdin forwarding and run-mode /dev/null.
sdk/​node/​tests/​integration/​wslc-e2e.test.ts Tests ordinary spawn input and EOF handling.
sdk/​node/​src/​v1/​lifecycle.ts Separates lifecycle run routing from ordinary spawning.
sdk/​node/​src/​v1/​index.ts Removes WithStdin exports.
sdk/​node/​src/​v1/​dev/​index.ts Routes Dev lifecycle runs through run-specific settings.
sdk/​node/​src/​v1/​container.ts Removes the separate stdin spawn helper.
sdk/​node/​src/​v1/​container-process.ts Updates stdin ownership documentation.
sdk/​node/​src/​bindings/​streaming.ts Consolidates spawn bindings and adds lifecycle run routing.
sdk/​node/​README.md Documents writable stdin on ordinary WSLC spawns.
sdk/​node/​CHANGELOG.md Records changed defaults and lifecycle cancellation limits.
sdk/​dotnet/​README.md Explains stdin disposal and wait behavior.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​MxcProcess.cs Clarifies when stdin can be unavailable.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​MxcLifecycle.cs Separates lifecycle run routing and enables WSLC stdin cleanup.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​MxcContainer.cs Consolidates spawn APIs and configures WSLC wait behavior.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​Dev/​MxcLifecycle.cs Updates Dev lifecycle routing and stdin cleanup.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​Dev/​MxcContainer.cs Enables WSLC stdin cleanup for Dev spawning.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​Dev/​DevJsonRequest.cs Identifies requests targeting WSLC.
sdk/​dotnet/​Microsoft.Mxc.Sdk/​V1/​ContainerAdapters.cs Removes retired stdin-specific adapter methods.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​V1/​SandboxAdapterTests.cs Removes the retired adapter-method test.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​V1/​MxcLifecycleWslcE2ETests.cs Tests ordinary lifecycle stdin and run-mode EOF behavior.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​V1/​MxcContainerWslcE2ETests.cs Migrates stdin scenarios to ordinary spawn operations.
sdk/​dotnet/​Microsoft.Mxc.Sdk.Tests/​DevEntryPointTests.cs Tests WSLC request identification.
sdk/​dotnet/​CHANGELOG.md Records changed stdin defaults and lifecycle limits.
docs/​development/​architecture/​container-lifecycle.md Updates lifecycle API inventory and stream descriptions.
docs/​backends/​wslc/​wslc-state-aware.md Documents lifecycle stdin and cancellation consequences.
docs/​backends/​wslc/​wsl-container-getting-started.md Updates stdin guidance to use ordinary spawn APIs.
docs/​api-reference/​rust/​v1/​types.md Removes retired process-producing API references.
docs/​api-reference/​rust/​v1/​dev.md Documents Dev stdin behavior and lifecycle limits.
docs/​api-reference/​rust/​v1/​api.md Updates spawn contracts and removes retired signatures.
docs/​api-reference/​node/​v1/​dev.md Documents Dev stdin behavior and lifecycle limits.
docs/​api-reference/​node/​v1/​api.md Updates spawn contracts and removes retired signatures.
docs/​api-reference/​dotnet/​v1/​types.md Removes retired stdin-specific method signatures.
docs/​api-reference/​dotnet/​v1/​dev.md Documents Dev stdin behavior and lifecycle limits.
docs/​api-reference/​dotnet/​v1/​api.md Updates spawn contracts and removes retired methods.

Review effort: Balanced

Comment thread src/mxc-sdk/src/core/mxc_engine/mod.rs Resolved
Comment thread src/mxc-sdk/src/lib.rs Resolved
Comment thread src/mxc-sdk/src/sandbox.rs Resolved
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 13, 2026 19:35

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.

🟢 Approval recommended

No active review issues were identified for the changes enabling writable stdin in ordinary WSLC spawn operations.

No open issues 🎉

4 resolved since last review

Review effort: Balanced

Resolve the conflicts with spawn_with_extended_options (#1761) and the
WSLC proxy tests (#1753):

- SpawnStdio::Pipes gives a WSLC command a writable stdin, as spawn does,
  and the .NET extended spawns close an untaken WSLC stdin on wait.
- Remove the WithStdin bindings and calls that came with #1761 and #1753;
  the stdin proxy tests use Spawn and spawn.
- Keep createStreamingDriverWith calling its spawn argument, so
  inherited-stdio spawns do not fall back to pipes.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Resolve the conflicts with the NVX SDK support (#1752):

- Keep both run entry points: the Node V1.Dev runInContainerJson uses
  mxc_exec_state_aware_capture_json, and the other run helpers keep
  mxc_exec_state_aware_for_run_json. Both give a WSLC command end-of-file.
- Remove the stdin exec option from #1752's Node binding changes, and
  rename the Node run flag from capture to forRun so it does not read as
  the capture output mode.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

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

The documentation overstates captured-stdin EOF guarantees for IsolationSession and omits the accepted WSLC V1 compatibility exception covering stdin handling and lifecycle timeout/kill behavior.

2 open issues

Review effort: Balanced

stderr; only `spawnInContainerWithStdin` also gives it a writable stdin, as
`spawnWithStdin` does for create-and-run execution.
IsolationSession and WSLC provide stdin, stdout, and stderr for live piped
execution. Captured execution gives the workload end-of-file on stdin.
accepts or rejects, instead of a backend-specific field.
- Mark every Rust SDK options struct `#[non_exhaustive]` so options can gain
fields without a new operation, and fold `spawn` and `spawn_with_stdin` into
fields without a new operation, and fold `spawn` into
@SohamDas2021
Soham Das (SohamDas2021) merged commit d7485b9 into main Nov 14, 2026
38 checks passed
@SohamDas2021
Soham Das (SohamDas2021) deleted the sohamdas2021-wslc-stdin-spawn branch November 14, 2026 03:22
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.

5 participants