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

3rd spawnSync() with shared options argument throws error #576

Closed
hail2u opened this issue Jan 23, 2015 · 3 comments
Closed

3rd spawnSync() with shared options argument throws error #576

hail2u opened this issue Jan 23, 2015 · 3 comments
Labels
child_process Issues and PRs related to the child_process subsystem.

Comments

@hail2u
Copy link

hail2u commented Jan 23, 2015

I have installed io.js, and start testing spawnSync(). However, calling spawnSync() 3 times with shared options argument throws an error.

test.js:

var spawn = require('child_process').spawnSync;

var ls;
var opts = {
  stdio: 'inherit'
};

ls = spawn('ls', [], opts);
ls = spawn('ls', [], opts);
ls = spawn('ls', [], opts);

Then run:

C:\Users\Kyo\Desktop>iojs test.js
desktop.ini  test.js
desktop.ini  test.js
child_process.js:905
      throw new TypeError('Incorrect value for stdio stream: ' +
            ^
TypeError: Incorrect value for stdio stream: { type: 'fd', fd: { type: 'fd', fd: 0 } }
    at child_process.js:905:13
    at Array.reduce (native)
    at _validateStdio (child_process.js:829:17)
    at spawnSync (child_process.js:1251:19)
    at Object.<anonymous> (c:\Users\Kyo\Desktop\test.js:13:10)
    at Module._compile (module.js:446:26)
    at Object.Module._extensions..js (module.js:464:10)
    at Module.load (module.js:341:32)
    at Function.Module._load (module.js:296:12)
    at Function.Module.runMain (module.js:487:10)

Tested on io.js v1.0.3 (Win64) on Windows 7 (64bit).

@vkurchatkin vkurchatkin added the child_process Issues and PRs related to the child_process subsystem. label Jan 23, 2015
@cjihrig
Copy link
Contributor

cjihrig commented Jan 23, 2015

This is not Windows specific. The problem appears to be that the options object is modified in the call.

@hail2u
Copy link
Author

hail2u commented Jan 23, 2015

Thanks! #579 looks good.

cjihrig added a commit that referenced this issue Jan 26, 2015
spawnSync() modifies the options argument. This commit makes
a copy of options before any modifications occur.

Fixes: #576
PR-URL: #579
Reviewed-By: Bert Belder <bertbelder@gmail.com>
@cjihrig
Copy link
Contributor

cjihrig commented Jan 26, 2015

Closed in 7854811

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.
Projects
None yet
Development

No branches or pull requests

3 participants