This is the mail archive of the
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.email@example.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:
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.
Michael Eager firstname.lastname@example.org 408-328-8426
MontaVista Software, Inc. 1237 E. Arques Ave., Sunnyvale, CA 94085