Skip to content

Commit 1e62781

Browse files
Merge pull request jashkenas#3953 from sixmen/fix_repl_fd_leak
fix history file descriptor leak
2 parents 234adef + 8b463cd commit 1e62781

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

lib/coffee-script/repl.js

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/repl.coffee

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@ addHistory = (repl, filename, maxSize) ->
108108
readFd = fs.openSync filename, 'r'
109109
buffer = new Buffer(size)
110110
fs.readSync readFd, buffer, 0, size, stat.size - size
111+
fs.close readFd
111112
# Set the history on the interpreter
112113
repl.rli.history = buffer.toString().split('\n').reverse()
113114
# If the history file was truncated we should pop off a potential partial line
@@ -125,7 +126,7 @@ addHistory = (repl, filename, maxSize) ->
125126
fs.write fd, "#{code}\n"
126127
lastLine = code
127128

128-
repl.rli.on 'exit', -> fs.close fd
129+
repl.on 'exit', -> fs.close fd
129130

130131
# Add a command to show the history stack
131132
repl.commands[getCommandId(repl, 'history')] =

0 commit comments

Comments
 (0)