Re: 4096 byte limit to /proc/PID/environ ?

James Pearson
2006-05-24T16:59:30Z

linux-os (Dick Johnson) wrote:
> On Wed, 24 May 2006, James Pearson wrote:
>
>
>>It appears that /proc/PID/environ only returns the first 4096 bytes of a
>>processes' environment.
>>
>>Is there any other way via userland to get the whole environment for a
>>process?
>>
>>Thanks
>>
>>James Pearson
>
>
>
> I think that /proc/PID/environ just returns the environment that
> existed when the process was created, irrespective of size. You
> can check this as:
>
> #include <stdio.h>
>
> main()
> {
> setenv("FOO=", "1234", 1);
> printf("%d\n", getpid());
> pause();
> }
>
> Variable "FOO" will not appear in /proc. It you set the environment
> in non-standard ways, overwriting the original, you can see it in
> /proc.

I'm not worried about that - more the fact that when I do:

% cat /proc/$$/environ | wc -c
4096
% env | wc -c
7329

/proc/PID/environ is truncated ...

James Pearson