Re:Setenv Is Not Thread Safe and C Doesn't Want to Fix It
by okr on Monday November 20, 2023 @03:11AM
(#38344418)
I can think of using libraries, that get their config through environment variables. So you start your program, modify environment, and then start up the rest.
Re:Setenv Is Not Thread Safe and C Doesn't Want to Fix It
by quickthrower2 on Monday November 20, 2023 @04:17AM
(#38345245)
Does the “and then” protect you here?
Re:Setenv Is Not Thread Safe and C Doesn't Want to Fix It
by okr on Monday November 20, 2023 @08:34AM
(#38347752)
No, not really. You never know when the library reads the enviroment variables. But i can make sure, that the parts under my control do not modify them after start.
Re:Setenv Is Not Thread Safe and C Doesn't Want to Fix It
by johanbcn on Monday November 20, 2023 @05:21AM
(#38345902)
Libraries shouldn't be reading environment variables, that responsibility should be only for the application.
Re:Setenv Is Not Thread Safe and C Doesn't Want to Fix It
by kuon on Monday November 20, 2023 @06:08AM
(#38346288)
It is common, out of my head SDL and pipewire do it.
Re:Setenv Is Not Thread Safe and C Doesn't Want to Fix It
by lelanthran on Monday November 20, 2023 @07:50AM
(#38347231)
They shouldn't, but if even the C standard library reads environment variables, then the bar is set pretty low for library designers.
Look up the mess around LOCALE sometime.
The best the programmer can do is perform all the setenv calls before spawning any threads or making any library calls.
I can't think of any time I had wanted to do that.
What exactly are the programs that break if this changes?