Better HN
topnewbestaskshowjobs
Log inSign up

DangerousDoctor

14 karma · joined Jun 29, 2023 (3y ago) · 2 submissions

Submissions

comment 3y ago · link · parent

The essential problem is that there is no thread-safe way to implement this while maintaining backwards compatibility -- applications can alter the environment block by changing the environ global pointer, applications can also alter the environment block by replacing individual pointers in the environ array, applications can also alter the environment block by altering the strings pointed to by the individual members of the environ array, applications can also alter the environment block by using setenv/putenv/etc.

Inserting a mutex into the setenv/getenv/etc. functions is pointless because applications are explicitly allowed to modify the environ pointer and array directly without any locking.