4 ms·
Mostly integration, for example some library can only be configured via env variables, but a developer might want to configure it from with-in the app it's inte
by dmytroi 3y ago
Mostly integration, for example some library can only be configured via env variables, but a developer might want to configure it from with-in the app it's integrated into and used from.
Also, few weeks ago I found a use for them when trying to pass configuration from Java/Kotlin to C++ library to be used during static constructors (invoked during dlopen) on Android, because at that phase native code cannot call back to JVM.
- guappa 3y ago> for example some library can only be configured via env variables library has already loaded when you call setenv, so what you're saying doesn't work in most cases. It seems to be a need to use poorly written libraries. You might consider fixing them instead.
- jonhohle 3y agoI agree that would be a poor implementation, but the library could be loaded at runtime using dlopen or equivalent. This issue with that “interface” is the environment is process global. If the library is being loaded dynamically (specifically for some task) it would seem that the parameters are local to that task and should be taken by some reentrent init method. Alternatively, the process could be forked and environment set in the child without concern for thread safety or polluting the environment (think of the children!).
- guappa 3y agoThe only library I've seen to use env vars is libc, which uses them to decide how malloc should behave for example.
- the_svd_doctor 3y agoSome libraries behaviour/API can be tweaked with env var. env var are read at runtime not loading time.
- guappa 3y agoCan you link one such library here?