News for hackers. Stuff that matters.
Re:C stdlib isn't threadsafe and even safe Rust didn't save us by fch42 on Thursday January 23, 2025 @05:32AM (#42802665)
The "cross platform" way of setting the environment is to set it "from outside" of the program - meaning, through the executor, whether that's the shell or the container runtime or even the kernel commandline if you insist to rewrite init in rust/go/zig/... It can be as-easy-as spawning your process via "env -i VAR1=... ... myprogram ..." - and given this also clears the dangers of env-insertion exploits, it's good practice.

(the argument that the horses have long bolted with respect to "just do the right think ok?!" here holds some water. I'm of the generation though where people on the internet could still tell each other they were wrong, and I assert that here; you're wrong if you believe a non-threadsafe unix interface is a bug. No matter what kind of restrictions around its use that means. You're still wrong if you assume the existence of such restrictions is a bug)

Re:C stdlib isn't threadsafe and even safe Rust didn't save us by gpderetta on Thursday January 23, 2025 @07:38AM (#42803379)
At the limit a program can execve itself with the new env.
Re:C stdlib isn't threadsafe and even safe Rust didn't save us by fch42 on Thursday January 23, 2025 @08:41AM (#42803896)
Indeed, and from my point of view, that's perfectly ok.
Re:C stdlib isn't threadsafe and even safe Rust didn't save us by GoblinSlayer on Friday January 24, 2025 @10:15AM (#42813839)
It's not cross platform. Does java provide such interface?