repl: close file descriptor of history file
PR-URL: https://github.com/nodejs/node/pull/28858 Reviewed-By: Rich Trott <rtrott@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
This commit is contained in:
parent
eadc3850fe
commit
3eea43af07
@ -93,6 +93,7 @@ function setupHistory(repl, historyPath, ready) {
|
||||
fs.ftruncate(hnd, 0, (err) => {
|
||||
repl._historyHandle = hnd;
|
||||
repl.on('line', online);
|
||||
repl.once('exit', onexit);
|
||||
|
||||
// Reading the file data out erases it
|
||||
repl.once('flushHistory', function() {
|
||||
@ -137,6 +138,15 @@ function setupHistory(repl, historyPath, ready) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onexit() {
|
||||
if (repl._flushing) {
|
||||
repl.once('flushHistory', onexit);
|
||||
return;
|
||||
}
|
||||
repl.off('line', online);
|
||||
fs.close(repl._historyHandle, () => {});
|
||||
}
|
||||
}
|
||||
|
||||
function _replHistoryMessage() {
|
||||
|
Loading…
x
Reference in New Issue
Block a user