Skip to content

Commit 7f06449

Browse files
committed
repl: close file descriptor of history file
1 parent 119682e commit 7f06449

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/internal/repl/history.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ function setupHistory(repl, historyPath, ready) {
9393
fs.ftruncate(hnd, 0, (err) => {
9494
repl._historyHandle = hnd;
9595
repl.on('line', online);
96+
repl.once('exit', onexit);
9697

9798
// Reading the file data out erases it
9899
repl.once('flushHistory', function() {
@@ -137,6 +138,15 @@ function setupHistory(repl, historyPath, ready) {
137138
}
138139
}
139140
}
141+
142+
function onexit() {
143+
if (repl._flushing) {
144+
repl.once('flushHistory', onexit);
145+
return;
146+
}
147+
repl.off('line', online);
148+
fs.close(repl._historyHandle, () => {});
149+
}
140150
}
141151

142152
function _replHistoryMessage() {

0 commit comments

Comments
 (0)