Skip to content

Can't use process.binding directly #50903

Discussion options

You must be logged in to vote

@CaledoniaProject

1.I have passed the example same arguments as child_process does, why won't it work?

It calls normalizeSpawnArguments to format the arguments before calling spawn_sync.spawn in child_process.spawnSync. the source code here

2.I can't lookup the errors in nodejs source code, I couldn't find that -22 means, does anyone know?

  • -22 means invalid params
  • pid = 0 means no process has been started

Maybe you should try the code as follows:

const spawn = process.binding('spawn_sync').spawn
let result = spawn({
  file: 'open',
  args: ['open', '/System/Applications/Calculator.app'],
  shell: true,
  detached: false,
  stdio: [ // the key is here, you should pass a valid stdio, …

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
1 reply
@CaledoniaProject
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by CaledoniaProject
Comment options

You must be logged in to vote
1 reply
@CaledoniaProject
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants