ENV VAR addresses



[Whether your post is on-topic for comp.lang.c is purely a
matter of opinion, since nobody has any authority to impose
an ANSI/ISO C topicality restriction on this newsgroup. If
you want more people available for replies, simply cross-post
to comp.lang.c *and* comp.unix.programmer.]

The two common ways of accessing the environment directly on
many Unix and Unix-like systems are as follows:

(1) Through a third argument to the main() function, typically
called 'envp' and used in a manner analogous to 'argv'.
(2) Through the global 'environ' variable, which is a
char **.

I need these infos cuz i need to put datas in the stack to be easily
picked up by the program itself, without using getenv, only with an
address.

I have some idea of what you're trying to do. What may help you is
that execle() and execve() let you control the environment of the
program you're executing. So instead of using setenv() or putenv()
in the calling program or screwing around with the shell, you can do
something like

char *my_env[] = {"MYVAR=mydata", NULL};

and pass that as the final argument to execle() or execve().
That may be one way of helping you with consistency, and you can
also use a consistent argv[0] length in those exec* calls.

However, there are various factors (including kernel modifications)
on modern systems that may make getting a consistent location across
program executions extremely difficult. Also, if you're trying to
execute assembly code stashed in the environment, this may not even
be allowed on some of these systems.

My advice is to make sure you're reading from material that is no
more than 5 years old.

Yours,
Han from China

.



Relevant Pages

  • Re: vba vs VB dotnet
    ... going to use to be developing with (such as ms-access). ... once again you're going to be using the.net environment. ... in many cases get a more consistent looking application when you develop ... In fact that advanced skill level ...
    (microsoft.public.access.formscoding)
  • Re: vba vs VB dotnet
    ... going to use to be developing with (such as ms-access). ... once again you're going to be using the.net environment. ... in many cases get a more consistent looking application when you develop ... In fact that advanced skill level ...
    (microsoft.public.access.formscoding)
  • Re: ADO and XP
    ... procedures (same stored procedure, different parameters) executing every ... but slowly degrading in an XP environment from the 7 to ... The VB6 app was compiled against ADO 2.5. ...
    (microsoft.public.data.ado)
  • Re: Strange Error Executing a map
    ... We have got a strange error executing a map that I havent seen before. ... key information about this is as follows: ... We have only seen this happen in one testing environment ...
    (microsoft.public.biztalk.general)
  • Re: GPS Locator for Your Dog -- An Idea Whose Time Has Come.
    ... I don't begrudge a nickel that I spend on my pets. ... Consistency from the enviro wacko croud seems we would hear a lot ... Us environmental wackos are interested in saving the environment ... So be consistent and collect credibility. ...
    (soc.retirement)