This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: getenv not thread safe
- From: Michael Eager <eager at mvista dot com>
- To: Ulrich Drepper <drepper at redhat dot com>
- Cc: Glibc Alpha <libc-alpha at sourceware dot redhat dot com>
- Date: Tue, 24 Feb 2004 08:32:50 -0800
- Subject: Re: getenv not thread safe
- Organization: MontaVista Software, Inc.
- References: <403AA64E.44F0138B@mvista.com> <403AAA33.5040009@redhat.com>
Ulrich Drepper wrote:
>
> Michael Eager wrote:
> > On an SMP system, it's possible that getenv may be walking the
> > environment while setenv is reallocating it.
>
> Then don't do this. POSIX explicitly says the *env functions are not
> thread safe.
Then perhaps the glibc documentation should not claim to be thread safe:
Environment Access
The value of an environment variable can be accessed with the getenv
function. This is declared in the header file stdlib.h. All of the
following functions can be safely used in multi-threaded programs.
It is made sure that concurrent modifications to the environment do
not lead to errors.
http://www.gnu.org/software/libc/manual/html_node/Environment-Access.html#Environment%20Access
--
Michael Eager eager@mvista.com 408-328-8426
MontaVista Software, Inc. 1237 E. Arques Ave., Sunnyvale, CA 94085