OpenVZ Forum


Home » General » Support » Pass environment variable via execve
Pass environment variable via execve [message #15957] Thu, 16 August 2007 23:34 Go to next message
AngerMCS is currently offline  AngerMCS
Messages: 2
Registered: August 2007
Junior Member
I have a "spawner" process that spawns other process within a vps. Problem is that the enivronment variables I pass with execve are not being passed to spawned processes. Does anyone know an easy way to do this?
Example code:
execve("/usr/sbin/vzctl", args, env);
where args={"exec", "101", "/path/to/process", ...}

Thanks!
Re: Pass environment variable via execve [message #15964 is a reply to message #15957] Fri, 17 August 2007 07:34 Go to previous messageGo to next message
Igor Sukhih is currently offline  Igor Sukhih
Messages: 21
Registered: May 2006
Junior Member
AngerMCS wrote on Thu, 16 August 2007 19:34

I have a "spawner" process that spawns other process within a vps. Problem is that the enivronment variables I pass with execve are not being passed to spawned processes. Does anyone know an easy way to do this?
Example code:
execve("/usr/sbin/vzctl", args, env);
where args={"exec", "101", "/path/to/process", ...}

Thanks!

As workaround It can be passed in command line
"FOO=bar /path/to/process"
Re: Pass environment variable via execve [message #15998 is a reply to message #15964] Fri, 17 August 2007 22:50 Go to previous message
AngerMCS is currently offline  AngerMCS
Messages: 2
Registered: August 2007
Junior Member
unfortunately that would require me to modify every single process that we spawn...

Anyone else have any ideas?

Edit: I tried recreating vzctl calls so that I could just use execve as though I were in the vps but that also failed.
syscall(511, 101);
env_create.veid=101;
env_create.flags=VE_ENTER;
fd=open("/dev/vzctl", O_RDWR);
ioctl(fd, VZCTL_ENV_CREATE, &env_create);
close(fd);
The box ended up hardlocking...

[Updated on: Fri, 17 August 2007 23:06]

Report message to a moderator

Previous Topic: Dedicating physical NIC ports to each VE without bridging, etc.
Next Topic: sysctl.conf ip_forward = 1 changes after reboot
Goto Forum:
  


Current Time: Mon Aug 12 15:55:45 GMT 2024

Total time taken to generate the page: 0.02850 seconds