Permalink
Browse files

Wait on `close` instead of `exit`.

If the version of Node.js is less than `0.7`, wait on a `"close"` event
from the ImageMagick process instead of `"exit"`. As of `0.7`, the
`exit` "fires when the child actually exits, `close` fires when all
stdio streams have closed."

See:

https://groups.google.com/forum/#!topic/nodejs/agsTbL-fco0/discussion
  • Loading branch information...
1 parent 158a638 commit d356d0b3883f8d82320a76c887550c59176655ac @bigeasy bigeasy committed Jul 3, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 imagemagick.js
View
@@ -79,7 +79,8 @@ function exec2(file, args /*, options, callback */) {
child.stdout.addListener("data", function (chunk) { std.out(chunk, options.encoding); });
child.stderr.addListener("data", function (chunk) { std.err(chunk, options.encoding); });
- child.addListener("exit", function (code, signal) {
+ var version = process.versions.node.split('.');
+ child.addListener(version[0] == 0 && version[1] < 7 ? "exit" : "close", function (code, signal) {
if (timeoutId) clearTimeout(timeoutId);
if (code === 0 && signal === null) {
std.finish(null);

0 comments on commit d356d0b

Please sign in to comment.