Nadav Har'El wrote:
On Wed, Jul 14, 2004, Shachar Shemesh wrote about "Re: Manipulating an environment variable of a running proccess...":Actually, if you are really worried about races, you can halt the program, make sure it's not in the middle of executing "getenv", and then change the var. This is not really concurrent execution, so the races are solveable.
Hi, I'm trying to manipulate a running procces's environment variableHook it like a debugger, and change it's runtime environment. It's your only more-or-less sane option.
while it's running.
But note that whether this will work will depend on the actual program.
If a program calls getenv() only when it needs a value, you'll be fine
(but you can have the danger of a race condition, if you accidentally change
the environment while it is being read).
Then again, what you are trying to do here is a dirty hack. I doubt races are your problem.
But if the program in question copies the environment to a different placeYes. That is a real problem. One the above is still capable of solving (i.e. - change the cache), but now we are getting into the "Really really ugly" areas.
in memory after reading it (e.g., I suppose shells do that), and use that
copy instead of the original one, you'll have to know exactly what the
program does to know where and how to change its concept of the environment
variables.
May I ask why you want to do that to begin with?
Shachar
-- Shachar Shemesh Lingnu Open Source Consulting ltd. http://www.lingnu.com/
================================================================= To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
