You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The child_process.execFile API (which finally leads to a new ChildProcess() and spawn call via the internal wrapper) spawns a process that uses the native /usr/bin/env node binary and NOT the currently used one.
All versions (including 5.1.1) are affected. Problem is visible among all Debian based servers and systems. Probably all GNU/unix systems are affected as shebang leads to the specific problem.
STEPS TO REPRODUCE
Download new nodejs binary to ~/mytest/node-new
Download old nodejs binary to ~/mytest/node-old (every version applies and 5.1.1 is affected, too - so just use a different version number for the sake of comparison)
The ~/mytest/child.js with the initial shebang that leads to the problem:
#!/usr/bin/env node
console.log(process.version);
Now execute the following command in the Terminal / bash:
cd~/mytest;
sudo cp ./node-old /usr/bin/node;# Yes, we WANT this for reproduction of issue
sudo chmod 0777 /usr/bin/node;# Just to be sure it's executable
chmod +x ./node-new;
chmod +x ./test.js;
chmod +x ./child.js;
./node-new ./test.js;
It is nowhere documented and child_process as an API name suggests that forks of the self-binary are made and no new processes are spawned when JS files are executed.
The text was updated successfully, but these errors were encountered:
Yes, or at least, it's the expected behavior. The shebang is interpreted by the kernel; it executes env which in turn scans the PATH for node and executes that.
It is nowhere documented and child_process as an API name suggests that forks of the self-binary are made and no new processes are spawned when JS files are executed.
I'm not sure how you came to that conclusion. The reference documentation is pretty explicit on that point, IMO at least.
The child_process.execFile API (which finally leads to a new ChildProcess() and spawn call via the internal wrapper) spawns a process that uses the native /usr/bin/env node binary and NOT the currently used one.
All versions (including 5.1.1) are affected. Problem is visible among all Debian based servers and systems. Probably all GNU/unix systems are affected as shebang leads to the specific problem.
STEPS TO REPRODUCE
REDUCED TEST CASE
The
~/mytest/test.js
:The
~/mytest/child.js
with the initial shebang that leads to the problem:Now execute the following command in the Terminal / bash:
TEST OUTPUT
./node-new app.js; v5.1.1 execution finished v4.2.4
Is this the wanted behaviour?
It is nowhere documented and child_process as an API name suggests that forks of the self-binary are made and no new processes are spawned when JS files are executed.
The text was updated successfully, but these errors were encountered: