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 <fishrock123@rocketmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
This commit is contained in:
Ruben Bridgewater 2018-12-11 23:22:20 +01:00 committed by Rich Trott
parent 49f1db47e2
commit 80ab537ee6

View File

@ -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 {}
};
}