apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Lucian Adrian Grijincu <lucian.griji...@avira.com>
Subject Re: Getting the current environment (all of it)
Date Mon, 20 Nov 2006 12:57:09 GMT
in windows you can access the environ variable the same way as you would
on unices, just that it's named _environ.
you just need to #define environ _environ and you've got the same name
on both windows and unices.

and I believe that you can do the same on other systems too

you could make a deep copy of this variable (let's name this copy
newenviron), append the new entries that you require(or modify existing
ones) and pass newenviron to apr_proc_create. this way you don't have to
modify the parent's variables and reset them.

en entry in environ is a NUL terminated string of the form
ENV_VARIABLE=ENV_VALUE and the last entry must be a NULL one.

HTH :)

Best regards,
Lucian Adrian Grijincu

Mike Mueller wrote:
> Hi,
> I'm using the apr_proc_create function to spawn a child process, and
> it takes an environment as a parameter.  What I want to do is get my
> environment, modify it slightly, and then pass it into the new process
> call.  However, there doesn't seem to be a method to access the
> environment as a whole (i.e. like "environ" in Linux).  The getenv
> function isn't sufficient, because you have to know the names of all
> the currently defined environment variables.
> Is there a method to get the entire environment via APR?  As of now,
> I'm stuck with modifying the parent's environment in place, spawning
> the child, and then reverting the parent's environment back to the
> original state.  (Haven't tried this yet, but I'm assuming it'll
> work.)
> Any input would be appreciated.
> Thanks,
> Mike

View raw message