Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wsl.exe Windows command never exits when run using child_process.spawn #18431

Closed
centsi opened this issue Jan 29, 2018 · 5 comments
Closed

wsl.exe Windows command never exits when run using child_process.spawn #18431

centsi opened this issue Jan 29, 2018 · 5 comments
Labels
child_process Issues and PRs related to the child_process subsystem. windows Issues and PRs related to the Windows platform.

Comments

@centsi
Copy link

centsi commented Jan 29, 2018

  • Version: v9.3.0
  • Platform: Windows 10 Fall Creators 64 bit
  • Subsystem: child_process

Running a command in Ubuntu on Windows using the "wsl" command works fine except the exit and / or close events never occur, and the script remains running until forcibly closed. I've specifically tested using child_process.spawn, but I believe it's the same with exec and execFile.

Example code follows (works fine if the wsl command is substituted with the "dir" windows command - and of course the first argument removed):

const child_process = require( 'child_process' );

const child = child_process.spawn( "C:\\Windows\\System32\\wsl.exe", [ "ls", "/" ] );

child.stdout.pipe( process.stdout );
child.stderr.pipe( process.stderr );

//Never fires
child.on( 'exit', function() {
	console.log( 'Exited.' );
});


//Never fires
child.on( 'close', function() {
	console.log( 'Closed.' );
});

Thanks - Lawrence

@bnoordhuis bnoordhuis added child_process Issues and PRs related to the child_process subsystem. windows Issues and PRs related to the Windows platform. labels Jan 29, 2018
@bzoz
Copy link
Contributor

bzoz commented Feb 5, 2018

This reproduces back to v6.0.0. Using spawnSync works as expected.

/cc @nodejs/platform-windows

@seishun
Copy link
Contributor

seishun commented Feb 5, 2018

That's because wsl doesn't exit, you can see it in Task Manager. Probably a wsl bug.

@bzoz
Copy link
Contributor

bzoz commented Feb 19, 2018

Investigated this. WSL is waiting for the stdin pipe to be closed. Adding child.stdin.end(); to the code solves this.

I think it is not an issue with Node, its only the way WSL handles its stdin.

@benhillis
Copy link

This is microsoft/WSL#4424, fix is inbound.

@corydorning
Copy link

this same issue occurs when using windows powershell. exit never occurs. not using wsl

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
child_process Issues and PRs related to the child_process subsystem. windows Issues and PRs related to the Windows platform.
Projects
None yet
Development

No branches or pull requests

6 participants