Hacker News new | ask | show | jobs
by andy_xor_andrew 403 days ago
ok, I'm hooked - how is setting an env var in the current process unsafe? My gut says it's not unsafe in a memory-ownership sense, but rather in a race condition sense?

whatever the issue is, "setting an env var is unsafe" is so interesting to me that I'm now craving a blog post explaining this

2 comments

It's a long standing bug, setenv and unsetenv are not thread-safe

https://www.evanjones.ca/setenv-is-not-thread-safe.html

I honestly think using setenv is just a terrible idea.
can you elaborate what is the simpelist alternative?
Simple, you don't set any env vars after starting new threads