-
Notifications
You must be signed in to change notification settings - Fork 29.7k
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
Spawned process don't trigger close or exit event #4500
Comments
What is the child process you're trying to spawn? Does it look for |
i spawn npm, if i spawn with Writing for |
Does this happen with the latest master version of node? Wondering if it's an echo of #4049. |
Don't think it's related, my code work fine when the process executed don't need user input.My issue occur only when i write to the process's stdin. Itried to attach every single event possible and none got triggered after the process stop |
@PIC-27 is this still an issue? If it is, can you please post a self contained example that reproduces the bug? Your original code sample can't be executed by collaborators trying to reproduce your problem. |
Closing, no follow-up. |
This appears to still be an issue. Not sure if it's npm or just how I'm using child_process. Edit: I found I needed to end npm's stdin Works (close and exit fired): var spawn = require('child_process').spawn;
var npm = spawn('npm.cmd');
npm.stdout.pipe(process.stdout);
process.stdin.pipe(npm.stdin);
npm.on('exit', function() {
console.log('exit');
})
npm.on('close', function() {
console.log('close');
}); Does not work (close and exit NOT fired): var spawn = require('child_process').spawn;
var npm = spawn('npm.cmd', ['init']);
npm.stdout.pipe(process.stdout);
process.stdin.pipe(npm.stdin);
npm.on('exit', function() {
console.log('exit');
})
npm.on('close', function() {
console.log('close');
}); |
I encountered the same issue in a Travis container, with the old Ubuntu Precise image. Switching to Ubuntu Trusty solved it. Edit: I used Node.js v8.1.4. |
@cpamp in the case of Edit: it also could be a change to npm. My version of npm is changing as I switch node versions. |
+1 |
I can still replicate @cpamp's issue in node |
i have a weird issue where sometimes it fires exit event and sometimes not. any can point me on a workaround? |
on Windows: for me "close" is not triggered if the process is started by task scheduler or pm2 but is if I start it myself from the command line. exit is triggered in both cases. |
Hi,
When i spawn a process and write in his stdin he will not trigger "close" or "exit" event.
i tried:
but it does nothing
I tried too
but it end the child process instantly.
Just in case it can have something to do with this issue, i'm using nw.js
Any idea?
The text was updated successfully, but these errors were encountered: