Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Thu, 5 Mar 2015 01:41:33 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: musl@...ts.openwall.com
Subject: Re: getenv_r

* William Ahern <william@...handClement.com> [2015-03-04 15:09:20 -0800]:
> I noticed that getenv is not thread-safe. Would there be any interest in
> accepting a patch to implement getenv_r (a NetBSD function) and internal
> locking? Other than leaving getenv, setenv, and putenv unsafe in threaded
> environments, the only other alternative is the ugliness that glibc,
> Solaris, and some others implement, which is basically to leak environ
> memory.

getenv is thread-safe if the environ is not modified

in a multi-threaded application environ modification
is unsafe and problematic even if you do the locks:
different threads may want different value for an env
var and when you read an env var you cannot know if
it is up to date when you want to use it.

does netbsd use getenv_r somewhere to solve some issue?

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.