From 09651080d1df3c5fff579ff1f85327a3c52e8cf6 Mon Sep 17 00:00:00 2001 From: Michael Kerrisk Date: Mon, 20 Feb 2017 08:30:48 +0100 Subject: [PATCH] proc.5: Clarify that /proc/PID/environ is set at time of execve(2) Reported-by: Mike Frysinger Signed-off-by: Michael Kerrisk --- man5/proc.5 | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/man5/proc.5 b/man5/proc.5 index 89a7c09ad..7f8031adb 100644 --- a/man5/proc.5 +++ b/man5/proc.5 @@ -477,7 +477,9 @@ check; see .BR ptrace (2). .TP .I /proc/[pid]/environ -This file contains the initial environment for the process. +This file contains the initial environment that was set +when the currently executing program was started via +.BR execve (2). The entries are separated by null bytes (\(aq\\0\(aq), and there may be a null byte at the end. Thus, to print out the environment of process 1, you would do: @@ -488,13 +490,17 @@ Thus, to print out the environment of process 1, you would do: .fi .in -Once a process starts modifying its environment +If, after an +.BR execve (2), +the process modifies its environment (e.g. by calling functions such as .BR putenv (3) or modifying the .BR environ (7) variable directly), -this file will not be kept up to date. +this file will +.I not +reflect those changes. Further, a process may change the memory this points to by calling .BR prctl (2)