Skip to content

Commit

Permalink
Bug where a pipe might call the cb twice. Reported by russell_h in IRC.
Browse files Browse the repository at this point in the history
  • Loading branch information
isaacs committed Aug 27, 2010
1 parent 3a55d02 commit 9b3e582
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
5 changes: 4 additions & 1 deletion lib/utils/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,19 @@ function exec (cmd, args, env, takeOver, cb) {
function logger (d) { if (d) process.binding("stdio").writeError(d+"") }
function pipe (cp1, cp2, cb) {
sys.pump(cp1.stdout, cp2.stdin)
var errState = null
if (log.level <= log.LEVEL.silly) {
cp1.stderr.on("data", logger)
cp2.stderr.on("data", logger)
}
cp1.on("exit", function (code) {
if (!code) return log.verbose(cp2.name || "<unknown>", "success")
cp2.kill()
cb(new Error( "Failed "+(cp1.name || "<unknown>")+"\nexited with "+code))
cb(errState = new Error(
"Failed "+(cp1.name || "<unknown>")+"\nexited with "+code))
})
cp2.on("exit", function (code) {
if (errState) return
if (!code) return log.verbose(cp1.name || "<unknown>", "success", cb)
cb(new Error( "Failed "+(cp2.name || "<unknown>")+"\nexited with "+code))
})
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ "name" : "npm"
, "description" : "A package manager for node"
, "version" : "0.1.27-2"
, "version" : "0.1.27-3"
, "homepage" : "http://npmjs.org/"
, "author" : "Isaac Z. Schlueter <[email protected]> (http://blog.izs.me)"
, "contributors" :
Expand Down

0 comments on commit 9b3e582

Please sign in to comment.