Reimplement "fix EXECPATH_FD premature close"

This commit is contained in:
Igor Klopov 2017-05-14 12:49:03 +03:00
parent 4d083419da
commit b041bb29b9
4 changed files with 12 additions and 8 deletions

View File

@ -201,7 +201,7 @@
--- node/src/node.js
+++ node/src/node.js
@@ -65,10 +65,53 @@
@@ -65,10 +65,54 @@
// There are various modes that Node can run in. The most common two
// are running from a script and running the REPL - but there are a few
// others like the debugger or running --eval arguments. Here we decide
@ -242,7 +242,8 @@
+ var result = readPrelude(fd);
+ if (result && result.undoPatch) {
+ fs.closeSync(fd);
+ // need to revert patch to node/lib/module.js
+ }
+ if (!result || result.undoPatch) {
+ var bindingFs = process.binding('fs');
+ fs.internalModuleStat = bindingFs.internalModuleStat;
+ fs.internalModuleReadFile = bindingFs.internalModuleReadFile;

View File

@ -262,7 +262,7 @@
}
--- node/src/node.js
+++ node/src/node.js
@@ -52,10 +52,53 @@
@@ -52,10 +52,54 @@
// There are various modes that Node can run in. The most common two
// are running from a script and running the REPL - but there are a few
// others like the debugger or running --eval arguments. Here we decide
@ -303,7 +303,8 @@
+ var result = readPrelude(fd);
+ if (result && result.undoPatch) {
+ fs.closeSync(fd);
+ // need to revert patch to node/lib/module.js
+ }
+ if (!result || result.undoPatch) {
+ var bindingFs = process.binding('fs');
+ fs.internalModuleStat = bindingFs.internalModuleStat;
+ fs.internalModuleReadFile = bindingFs.internalModuleReadFile;

View File

@ -173,7 +173,7 @@
// set process.send()
--- node/lib/internal/bootstrap_node.js
+++ node/lib/internal/bootstrap_node.js
@@ -72,10 +72,53 @@
@@ -72,10 +72,54 @@
// There are various modes that Node can run in. The most common two
// are running from a script and running the REPL - but there are a few
// others like the debugger or running --eval arguments. Here we decide
@ -214,7 +214,8 @@
+ var result = readPrelude(fd);
+ if (result && result.undoPatch) {
+ fs.closeSync(fd);
+ // need to revert patch to node/lib/module.js
+ }
+ if (!result || result.undoPatch) {
+ var bindingFs = process.binding('fs');
+ fs.internalModuleStat = bindingFs.internalModuleStat;
+ fs.internalModuleReadFile = bindingFs.internalModuleReadFile;

View File

@ -173,7 +173,7 @@
// set process.send()
--- node/lib/internal/bootstrap_node.js
+++ node/lib/internal/bootstrap_node.js
@@ -62,10 +62,53 @@
@@ -62,10 +62,54 @@
// There are various modes that Node can run in. The most common two
// are running from a script and running the REPL - but there are a few
// others like the debugger or running --eval arguments. Here we decide
@ -214,7 +214,8 @@
+ var result = readPrelude(fd);
+ if (result && result.undoPatch) {
+ fs.closeSync(fd);
+ // need to revert patch to node/lib/module.js
+ }
+ if (!result || result.undoPatch) {
+ var bindingFs = process.binding('fs');
+ fs.internalModuleStat = bindingFs.internalModuleStat;
+ fs.internalModuleReadFile = bindingFs.internalModuleReadFile;