From 80ab537ee6fa5513399b86ab439d954387d88772 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 698e73d97f14b5..9416f15383b088 100644 --- a/lib/internal/process/warning.js +++ b/lib/internal/process/warning.js @@ -29,7 +29,9 @@ function writeOut(message) { function onClose(fd) { return () => { if (fs === null) fs = require('fs'); - fs.close(fd, nop); + try { + fs.closeSync(fd); + } catch {} }; }