-
Sorry if this is a dumb question but I've struggled with it for a couple of hours to no avail. Given this sleep 100 Why does I initially thought that it had to do with spawn not blocking but I've failed to reproduce it using a minimal example (execution waits until sleep returns): // app.js , run it using 'node app.js'
const spawn = require('child_process').spawn
const child = spawn('sleep',['10'], {
stdio: 'inherit',
shell: true
})
child.on('exit', c => console.log(c)) |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 5 replies
-
It's actually a very interesting question and I must admit I haven't tested that many cases yet with the exec command. |
Beta Was this translation helpful? Give feedback.
-
Thanks a lot for the super fast response! |
Beta Was this translation helpful? Give feedback.
I need to test more but updating with this seems to work:
That way the parent program is forced to wait for the child to exit.