Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

On windows, if you spawn a child process, it raises an exception when outputting anything #1899

Closed
catamphetamine opened this issue Oct 16, 2011 · 7 comments

Comments

@catamphetamine
Copy link

Try to run this example on Node 0.5.9:

node parent

parent.js:

console.log('hello from parent')

var process = require('child_process').spawn("node", ["child.js"])

process.stdout.addListener('data', function (data) {
    require('sys').print(data)
    process.stdout.write(data)
})

// Error: write EINVAL
process.stderr.addListener('data', function (data) {
    require('sys').print(data)
})

child.js:

console.log('hello from child')

The child process crashes with "Error: write EINVAL" exception.

@ghost ghost assigned piscisaureus Oct 18, 2011
@japj
Copy link

japj commented Oct 20, 2011

if I remember correctly (from irc), this issue also prevents 'vows test/*.js' to be run on windows, since vows spawns a child process for each test file to be handled and parses the output to determine pass/failure of the test.

@mmalecki
Copy link

Actually, it prevents vows --isolate. --isolate spawns each file as a separate process and waits for JSON output from these processes (which fails hard on Windows).

@piscisaureus Would a test case be useful for you? I guess we want a regress for this anyway.

@byteshijinn
Copy link

you may not use 'process' as a variable name.try like this

console.log('hello from parent')

var child = require('child_process').spawn("node", ["child.js"])

child .stdout.addListener('data', function (data) {
require('util').print(data)
process.stdout.write(data)
})

@mmalecki
Copy link

@bombworm This has been confirmed with this test case and it's not a result of using process as variable name.
@piscisaureus AFAIK, it's fixed, mind closing the issue?

@catamphetamine
Copy link
Author

Thanks for your comment, bombworm, but have your tried it yourself?
I mean, did you try launching this piece of code on Windose yourself?
Because when I launch it, the error stays the same: 'write EINVAL'

console.log('hello from parent')

var child = require('child_process').spawn("node", ["child.js"])

child.stdout.addListener('data', function (data) {
    require('util').print(data)
    process.stdout.write(data)
})

// Error: write EINVAL
child.stderr.addListener('data', function (data) {
    require('util').print(data)
})

@byteshijinn
Copy link

@kuchumovN I tried on windows with node 0.5.10 and no error appeared screenshot

@catamphetamine
Copy link
Author

@bombworm
Oh, really, it works.
Thanks for the screenshot.
You forgot to mention, that i should update to 0.5.10.
Okay then, I'm closing the issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants