diff options
author | Peter Zhu <[email protected]> | 2024-05-01 11:31:07 -0400 |
---|---|---|
committer | Peter Zhu <[email protected]> | 2024-05-02 10:12:58 -0400 |
commit | e7d20623cbc6eb86c95357c344370cc39d29f8a3 (patch) | |
tree | 1496ce80821b24dcf13ee61f83ac128806352fc3 /missing/setproctitle.c | |
parent | 4f69d318b8667eb10596aaec9b75992a3265f66d (diff) |
Add comments in setproctitle.c
Diffstat (limited to 'missing/setproctitle.c')
-rw-r--r-- | missing/setproctitle.c | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/missing/setproctitle.c b/missing/setproctitle.c index 72e214e51c..5b2dfa65ce 100644 --- a/missing/setproctitle.c +++ b/missing/setproctitle.c @@ -87,8 +87,29 @@ static char **argv1_addr = NULL; #endif #if ALLOCATE_ENVIRON +/* system_environ is the value of environ before we allocate a custom buffer. + * + * We use this to restore environ in ruby_free_proctitle. + */ static char **system_environ = NULL; +/* orig_environ is the buffer we allocate for environ. + * + * We use this to free this buffer in ruby_free_proctitle. When we add new + * environment variables using setenv, the system may change environ to a + * different buffer and will not free the original buffer, so we need to hold + * onto this so we can free it in ruby_free_proctitle. + * + * We must not free any of the contents because it may change if the system + * updates existing environment variables. + */ static char **orig_environ = NULL; +/* alloc_environ is a copy of orig_environ. + * + * We use this to free all the original string copies that were in orig_environ. + * Since environ could be changed to point to strings allocated by the system + * if environment variables are updated, so we need this to point to the + * original strings. + */ static char **alloc_environ = NULL; #endif |