Nadav Har'El wrote:

On Wed, Jul 14, 2004, Shachar Shemesh wrote about "Re: Manipulating an environment variable of a running proccess...":


Hi, I'm trying to manipulate a running procces's environment variable
while it's running.


Hook it like a debugger, and change it's runtime environment. It's your only more-or-less sane option.



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).


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.

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 place
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.


Yes. 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.

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]



Reply via email to