From: "Michael W. Ryder" <_mwryder@...> Date: 2008-04-16T07:35:10+09:00 Subject: Re: exec with environment? Ian Peters-campbell wrote: > Robert Klemme wrote: >> On 12.04.2008 16:23, Marc Heiler wrote: >>> I believe something like >>> ENV['foo'] = 'bar' >>> is enough. >> This is not what the OP asked for IIRC. He wanted to modify the >> environment of a process started from his Ruby program not the program's >> own environment. This question was likely inspired by the POSIX C >> function /execle/. >> >>> You can try it, compile a small GNU configure program via ruby >>> ENV['CFLAGS'] = 'O2' >>> should work, I am quite confident that it will work. >> It will likely work but also affect the program's own environment as >> well as that of all subsequent started sub programs. >> >> Kind regards >> >> robert > > Yes, apologies if my original question was not clear. I have a Ruby > script which starts a new session D-Bus, and then starts two other > applications which need to be connected to this new D-Bus. I have > control over the source code of one of these applications, and so can > order it to connect to a bus whose address I pass to it at startup. The > second application is effectively a black box though...I can only > control whether it connects to what it believes to be the system or > session bus. > > Thus, I need a way to clobber its DBUS_SESSION_BUS_ADDRESS at startup. > I am already setting the ENV value on the parent process, but it is not > passing the modified environment to the process launched via exec(). > So...I am looking for a way to push an environment to the "black box" > process while still managing to retain the PID in the parent (as I still > need to be able to signal the "black box." > > I hope that is more clear, and any help that people can provide would be > appreciated :) If you are "permanently" changing the environment have you tried using export to change the setting in the main program?