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

From: James Pearson
Date: Wed May 24 2006 - 12:58:41 EST


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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/