Skip to content

Commit

Permalink
process library - remove fds from event loop before closing
Browse files Browse the repository at this point in the history
  • Loading branch information
billywhizz committed Feb 18, 2021
1 parent 32a5c12 commit b79fc1d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions lib/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,17 @@ function watch (p) {
const timer = just.setInterval(() => {
const [status, kpid] = waitpid(new Uint32Array(2), p.pid)
if (kpid === p.pid) {
just.sys.nextTick(() => just.clearInterval(timer))
// todo - if our child process has children stdio buffers could still have data
just.sys.nextTick(() => {
just.clearInterval(timer)
loop.remove(p.stdin[WRITABLE])
close(p.stdin[WRITABLE])
loop.remove(p.stdout[READABLE])
close(p.stdout[READABLE])
loop.remove(p.stderr[READABLE])
close(p.stderr[READABLE])
})
resolve(status)
close(p.stdin[WRITABLE])
close(p.stdout[READABLE])
close(p.stderr[READABLE])
}
}, 10)
})
Expand Down

0 comments on commit b79fc1d

Please sign in to comment.