4 ms·
I think it’s borderline broken. Such APIs are defensible if you don’t have threads and memory is very scarce. Reading https://man.freebsd.org/cgi/man.cgi?geten
by Someone 3y ago
I think it’s borderline broken. Such APIs are defensible if you don’t have threads and memory is very scarce.
Reading https://man.freebsd.org/cgi/man.cgi?getenv(3) https://man.freebsd.org/cgi/man.cgi?getenv(3) it was introduced in Version 7 AT&T UNIX (https://en.wikipedia.org/wiki/Version_7_Unix https://en.wikipedia.org/wiki/Version_7_Unix). That didn’t have threads.
Now, was memory scarce? The PDP-11 it was designed for could have megabytes of RAM, but I wouldn’t know what the smallest machines this ran on had, and of course, those systems were multi-user.
So, maybe, thisxwas a good choice, but it also could be an early example of using a small system, hacker mindset on machines that didn’t need that anymore.
- numeromancer 3y agoThe text implies that any second call to getenv invalidates the returned value of any prior call to getenv; even without threads, without calling setenv, a second call to the function invalidates the return from an earlier call. I re-affirm my conclusion, without qualification: BROKEN.