Skip to content

WSL2 does not set up file descriptors for sub processes on the host #14201

Closed

Description

@OrKoN

Windows Version

10.0.22631.6199

WSL Version

2.6.3.0

Are you using WSL 1 or WSL 2?

  • WSL 2
  • WSL 1

Kernel Version

6.6.87.2-1

Distro Version

Ubuntu 24.04

Other Software

Node 24.13.0

Repro Steps

The repro uses Node.js but in the original problem the parent process is node and the child process is Google Chrome.

The parent script starts a subprocess with 5 file descriptors. stdin, stdout, stderr + 2 custom ones. It sends data to the child over the fd 3.

// wslParent.mjs
import { spawn } from "node:child_process";

console.log("spawn")

const child = spawn('node.exe', ["wslChild.mjs"], {
    stdio: ["inherit", "inherit", "pipe", "pipe", "pipe"],
});

console.log("writing to child via fd 3")
child.stdio[3].write('test');

child.on('error', err => {
    console.log('error', err);
});

child.stdio[4].on('data', data => {
    console.log('fd4', data.toString('utf-8'));
})

child.stderr.on('data', data => {
    console.log('stderr', data.toString('utf-8'));
})

setTimeout(() => {
    console.log("parent done");
    process.exit(0)
}, 1000)

The child process reads the data from fd 3.

// wslChild.mjs
import fs from 'node:fs';

const stream = fs.createReadStream(null, { fd: 3 });

stream.on('data', data => {
    console.log('child fd3', data.toString('utf-8'));
})

setTimeout(() => {
    console.log("child done");
    stream.close();
    process.exit(0)
}, 1000)

Run node wslParent.mjs inside the WSL's Ubuntu terminal.

Expected Behavior

This should print the child fd3 test. If you replace node.exe with node to use the node within Ubuntu it works. If node.exe on the host is used, it fails.

Actual Behavior

It errors: "Error: EBADF: bad file descriptor, close" indicating that the file descriptor was not opened.

Diagnostic Logs

No response

Activity

  1. github-actions commented on Feb 12, 2026

    @github-actions
    Contributor

    Logs are required for review from WSL team

    If this a feature request, please reply with '/feature'. If this is a question, reply with '/question'.
    Otherwise, please attach logs by following the instructions below, your issue will not be reviewed unless they are added. These logs will help us understand what is going on in your machine.

    How to collect WSL logs

    Download and execute collect-wsl-logs.ps1 in an administrative powershell prompt:

    Invoke-WebRequest -UseBasicParsing "https://raw.githubusercontent.com/microsoft/WSL/master/diagnostics/collect-wsl-logs.ps1" -OutFile collect-wsl-logs.ps1
    Set-ExecutionPolicy Bypass -Scope Process -Force
    .\collect-wsl-logs.ps1
    

    The script will output the path of the log file once done.

    If this is a networking issue, please use .\collect-wsl-logs.ps1 -LogProfile networking instead, following the instructions in Collect WSL logs for networking issues

    Once completed please upload the output files to this GitHub issue.

    See Collect WSL logs (recommended method).

    If you choose to email these logs instead of attaching them to the bug, please send them to [email protected] with the GitHub issue number in the subject, and include a link to your GitHub issue comment in the message body, and reply with '/emailed-logs'.

  2. OrKoN commented on Feb 12, 2026

    @OrKoN
    Author

    /emailed-logs

  3. github-actions commented on Feb 12, 2026

    @github-actions
    Contributor
    Diagnostic information
    Found '/emailed-logs', adding tag 'emailed-logs'
    
  4. added
    emailed-logs
    on Feb 12, 2026
  5. OneBlue commented on Feb 24, 2026

    @OneBlue
    Collaborator

    Thank you for reporting this Alex Rudenko (@OrKoN).

    It looks like you're trying to pass a fd from a Linux process running inside WSL to a Windows process, which is unsupported (there's no way to have file descriptors in Linux be used from Windows).

    Closing since this is by design.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bydesignemailed-logs

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions