The trouble with this idea is that it wouldn't truly be safe as long as environ
and the third argument to C main
still exist. And there are legitimate use cases for both. Also it would reopen the argument, and despite Drepper no longer being involved, I doubt anyone has the appetite for that.
The hypothetical "crash if there are multiple threads active" versions of setenv
and putenv
do not entirely solve the problem either, for the same reason -- nothing can prevent someone from scribbling on the environment block directly, via environ
-- but they would only enforce a rule that already has consensus within both glibc and the POSIX committee, so they're an easier sell.
I have never learned Java in detail, but I have the impression that it was designed around the assumption that any nontrivial program will have multiple threads. Myself, I think this was a design error, and there are many reasons to want to write resolutely single-threaded programs even today. And, if you know there will only ever be one thread, there is no problem with using these old-fashioned APIs as they were expected to be used, back in the 1970s.