From a4068d9827fbbebfa1a99b6e50435e6256c4bc2a Mon Sep 17 00:00:00 2001 From: Ruben Bridgewater Date: Tue, 11 Dec 2018 23:22:20 +0100 Subject: [PATCH] process: properly close file descriptor on exit This makes sure the file descriptor is closed syncronously on exit instead of using the asyncronous version which should not be used on exit. PR-URL: https://github.com/nodejs/node/pull/24972 Refs: https://github.com/nodejs/node/pull/24965/files#r240770314 Reviewed-By: Jeremiah Senkpiel Reviewed-By: Anna Henningsen --- lib/internal/process/warning.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/internal/process/warning.js b/lib/internal/process/warning.js index f7c9ab9b7a9326..9fabd0687a1a07 100644 --- a/lib/internal/process/warning.js +++ b/lib/internal/process/warning.js @@ -22,7 +22,9 @@ function writeOut(message) { function onClose(fd) { return () => { if (fs === null) fs = require('fs'); - fs.close(fd, nop); + try { + fs.closeSync(fd); + } catch {} }; }