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

IPC with fd>2 doesn't work #16553

Closed
seishun opened this issue Oct 27, 2017 · 4 comments
Closed

IPC with fd>2 doesn't work #16553

seishun opened this issue Oct 27, 2017 · 4 comments
Labels
child_process Issues and PRs related to the child_process subsystem. windows Issues and PRs related to the Windows platform.

Comments

@seishun
Copy link
Contributor

seishun commented Oct 27, 2017

  • Version: master
  • Platform: Windows 10 64-bit
  • Subsystem: child_process

index.js

const spawn = require('child_process').spawn
const path = require('path')

let dir = path.join(__dirname, 'child.js')
let server = spawn(process.argv0, [`"${dir}"`], {
  stdio: [0, 1, 2, 'ipc'],
  shell: true,
})

child.js

Output:

child_process.js:107
  p.open(fd);
    ^

Error: EBADF: bad file descriptor, uv_pipe_open
    at Object.exports._forkChild (child_process.js:107:5)
    at Object.setupChannel (internal/process.js:237:8)
    at startup (bootstrap_node.js:73:16)
    at bootstrap_node.js:613:3

Before I start digging further into this, I'd like someone to confirm that this code is valid and should work.

@seishun seishun added child_process Issues and PRs related to the child_process subsystem. windows Issues and PRs related to the Windows platform. labels Oct 27, 2017
@bzoz
Copy link
Contributor

bzoz commented Oct 27, 2017

Does it also fail with shell: false?

@seishun
Copy link
Contributor Author

seishun commented Oct 27, 2017

This doesn't fail:

const spawn = require('child_process').spawn
const path = require('path')

let dir = path.join(__dirname, 'child.js')
let server = spawn(process.argv0, [dir], {
  stdio: [0, 1, 2, 'ipc'],
})

@bnoordhuis
Copy link
Member

Before I start digging further into this, I'd like someone to confirm that this code is valid and should work.

Not a bug, in all likelihood. I expect the shell doesn't pass on the extra file descriptor (but does pass on the NODE_CHANNEL_FD environment variable), resulting in the behavior you see.

@jasnell
Copy link
Member

jasnell commented Jun 19, 2020

There's been no further activity here in over 2 years. Closing

@jasnell jasnell closed this as completed Jun 19, 2020
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

4 participants