Skip to content

Commit 81b38e4

Browse files
committed
Add child process close event handler
1 parent 5d0a30c commit 81b38e4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

lib/pdf.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ PDF.prototype.toStream = function PdfToStream (callback) {
6363
}
6464

6565
stream.on('end', function () {
66-
fs.unlink(res.filename, function (err) {
66+
fs.unlink(res.filename, function unlinkPdfFile (err) {
6767
if (err) console.log('html-pdf:', err)
6868
})
6969
})
@@ -134,15 +134,15 @@ PDF.prototype.exec = function PdfExec (callback) {
134134
child.on('error', function onError (err) { respond(null, err) })
135135

136136
// An exit event is most likely an error because we didn't get any data at this point
137+
child.on('close', respond)
137138
child.on('exit', respond)
138139

139140
var config = JSON.stringify({html: this.html, options: this.options})
140-
return child.stdin.write(config + '\n', 'utf8')
141+
child.stdin.write(config + '\n', 'utf8')
142+
child.stdin.end()
141143
}
142144

143145
function kill (child, onData, onError) {
144-
child.stdout.removeListener('data', onData)
145-
child.stderr.removeListener('data', onError)
146146
child.stdin.end()
147147
child.kill()
148148
}

0 commit comments

Comments
 (0)