4 ms·
> Inserting a mutex into the setenv/getenv/etc. functions is pointless because applications are explicitly allowed to modify the environ pointer and array direc
by jcelerier 3y ago
> 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.
by that logic mutex themselves are pointless because nothing ever forces you to use them, even in memory-safe languages you can still access /dev/mem and change bytes? It's stil a useful thing to have.
- PhilipRoman 3y agoThe difference is that modifying the environ pointer is explicitly supported behaviour in the standard, poking through /dev/mem is not. Although I guess a middle ground solution wouldn't be too bad either - most programs don't modify environ directly, so POSIX could offer thread safety for the functions and make multithreading through "environ" UB. This is already kind of explained in the standard: https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/functions/environ.html https://pubs.opengroup.org/onlinepubs/9699919799.2018edition...
- jcelerier 3y ago> The difference is that modifying the environ pointer is explicitly supported behaviour in the standard they just have to fix the standard. e.g. in my country they manage to improve for instance the standard for electrical plugs every three years, there is NO REASON posix cannot do the same