Can't use process.binding directly #4807
-
|
I'm trying to bypass a JS sandbox and I need to invoke spawn without child_process, so I used the following to test it: However nodejs returns error My questions,
|
Beta Was this translation helpful? Give feedback.
Replies: 0 comments 5 replies
-
|
parameters of |
Beta Was this translation helpful? Give feedback.
-
It calls
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, if stdio is `null` or `undefined` it will returns -22
{ type: 'pipe', readable: true, writable: false }
]
})
console.log(result)Hope this helps you. |
Beta Was this translation helpful? Give feedback.
-
|
Yes, JimmyDaddy is right. The parameters look like this. |
Beta Was this translation helpful? Give feedback.

@CaledoniaProject
It calls
normalizeSpawnArgumentsto format the arguments before callingspawn_sync.spawninchild_process.spawnSync. the source code here-22means invalid paramspid = 0means no process has been startedMaybe you should try the code as follows: