3 ms·
I sometimes call setenv very early in a program's execution to affect what certain libraries do. For example, I have some projects which do `if (!getenv("GST_DE
by mort96 2y ago
I sometimes call setenv very early in a program's execution to affect what certain libraries do. For example, I have some projects which do `if (!getenv("GST_DEBUG") { setenv("GST_DEBUG", "4"); }` at the beginning of main (before `gst_init()`), in order to print warning and error messages to the terminal when using the gstreamer library. I think I've done similar to set ASAN_OPTIONS as well.
There's also the use-case of wrapper programs; programs which do a thing and then call exec. If the wrapper wants to set environment variables for the exec'd program, you could use execvpe, but setenv + execvp is simpler.