On Wed, Jun 02, 2021 at 10:26:24AM +0200, Jan Engelhardt wrote:
On Wednesday 2021-06-02 09:40, Adam Majer wrote:
symlinks -- they only really allow a SINGLE choice to be preferred.
It so happens that any ordering of elements in a set implies that one is the first.
But, what happens when you run `node14` and then that program re-execs #!/usr/bin/node in a subprocess? The subprocess runs node16 and you are out of luck.
exec is a willfull boundary. (Just like /usr/libexec and /usr/bin.) Programs using these mechanisms _must not_ care about changes in architecture, language, memory layout, etc. nodejs's behavior sounds incredibly stupid.
Well, it needs to exec g++ and python3 - that's the GYP, build system. This in turns needs to find parameters, which is from node process and you end up with wrong one.
I expect the same issue exists with ruby and python3 and other interpreters
python3 would hardly exec /usr/bin/python (v2). They're still sane.
python3 exec python3, of course. But what happens if you have python3.8 and python3.10 installed and want your app to use python3.8? That app then starts a child process and you are in python3.10 then?
The second issue that comes up is inability to actually manage preferences on a user level. Imagine you have all editors installed on a multi-user system. The user cannot specify their preferences bypass update-alternatives and resort to manual symlink hackery in ~/.bin or similar. [The plan is] moving the logic into a library. The /usr/bin/node would link to it and exec the preferred node version based on user preferences
Making /usr/bin/editor a program that painstakingly loads a ton of ELF libraries, parses config files is such a bad idea. Both
export EDITOR=/usr/bin/joe alias editor='$EDITOR' export PAGER=/usr/bin/less
or
PATH="$HOME/bin:$PATH" ln -s /usr/bin/joe ~/bin/editor
exec the "right" program, "right away" (after perhaps a search through PATH - it's still a _lot_ less syscalls).
Not sure editor cares about syscall overhead. But yes, there is about 3 or 4 syscalls + the exec(). Starting actual interpreters like bash is a lot more overhead. - Adam