I m assing file name dynamically using setenv as folows:
I m curious if this is per process?
If i have multiple processes running this code but taking different file names, would there be any collisions?
Lets say I have process 1
and process 2
would i have any problems doing this?
preguntado el 01 de febrero de 12 a las 22:02
The environment you set with
setenv() is per process. Essentially it is just a memory area in your process. At least, this is what does on UNIX systems. Unlike
getenv() it isn't part of either the C or the C++ standard but it is part of POSIX. What it does on non-POSIX systems, if it exists, may be something different.
Environment variables are platform specific. I don't think setenv() works with Windows, so assuming you are talking about a program running on Linux, you should be fine. setenv() sets environment variables with process scope (and of course shared amongst forked threads).
To my knowledge, on all modern operating systems, each process has a seperate environment block which is usually constructed when the process is created. (e.g. during
NtCreateProcess() on a Windows system) or the equivalent for Linux/Unix/Other.
_putenv() will work on Windows wheras
setenv() will work on Linux/Unix.