Hello Bart,

Appreciate your inputs thank you.

Best,
Vamsi kundeti

On 7/15/06, Bart Smaalders <[EMAIL PROTECTED]> wrote:
vamsi krishna wrote:
> Hello All,
>
> o Where is the environment (all environment variables) mapped in the
> process virtual address space? is it on the heap? or on the stack?

% cat > test.c
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int main()
{
         printf("0x%x\n", getenv("HOME"));
         pause();
}
% cc -o test test.c
% ./test &
[1] 7184
0x8047c0c %
% pmap 7184
7184::   ./test
08046000       8K rwx--    [ stack ]
08050000       4K r-x--  /tmp/test
08060000       4K rwx--  /tmp/test
BFEC0000      24K rwx--    [ anon ]
BFED0000       4K rwx--    [ anon ]
BFEE0000     760K r-x--  /lib/libc.so.1
BFFAE000      24K rw---  /lib/libc.so.1
BFFB4000       8K rw---  /lib/libc.so.1
BFFC6000     148K r-x--  /lib/ld.so.1
BFFFB000       4K rwx--  /lib/ld.so.1
BFFFC000       8K rwx--  /lib/ld.so.1
  total       996K
%

So the answer clearly is stack.

>
> o Also I have seen some code long back which uses 'char *environ' to
> create a new environment, is this documented some where? (man n
> environ) doesnt give me any information about this 'char *environ'
> variable.

That should be

char *environ[];

which contains a set of character strings of the form NAME=VALUE

You can read this, but you do so at your peril if other threads are busy
modifying it.



--
Bart Smaalders                  Solaris Kernel Performance
[EMAIL PROTECTED]         http://blogs.sun.com/barts

_______________________________________________
opensolaris-code mailing list
[email protected]
http://mail.opensolaris.org/mailman/listinfo/opensolaris-code

Reply via email to