From 8084f0f9797daf83bf6da698e5e1e5784c11601b Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Sun, 23 Feb 2014 16:48:17 +0100 Subject: ose: Add unsetenv and update to use get_env Before get_envp was used and this caused the environment variables to not be accessible in the correct way by use debug tools. --- erts/emulator/sys/ose/sys.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) (limited to 'erts/emulator/sys') diff --git a/erts/emulator/sys/ose/sys.c b/erts/emulator/sys/ose/sys.c index c475aafe38..4fd740b02a 100644 --- a/erts/emulator/sys/ose/sys.c +++ b/erts/emulator/sys/ose/sys.c @@ -1530,24 +1530,24 @@ int erts_sys_putenv(char *key, char *value) { int res; - char *env; - Uint need = strlen(key) + strlen(value) + 2; -#ifdef HAVE_COPYING_PUTENV - env = erts_alloc(ERTS_ALC_T_TMP, need); -#else - env = erts_alloc(ERTS_ALC_T_PUTENV_STR, need); - erts_smp_atomic_add_nob(&sys_misc_mem_sz, need); -#endif - strcpy(env,key); - strcat(env,"="); - strcat(env,value); erts_smp_rwmtx_rwlock(&environ_rwmtx); - res = putenv(env); + res = set_env(get_bid(current_process()), key, + value); erts_smp_rwmtx_rwunlock(&environ_rwmtx); -#ifdef HAVE_COPYING_PUTENV - erts_free(ERTS_ALC_T_TMP, env); -#endif + return res; +} + + +int +erts_sys_unsetenv(char *key) +{ + int res; + + erts_smp_rwmtx_rwlock(&environ_rwmtx); + res = set_env(get_bid(current_process()),key,NULL); + erts_smp_rwmtx_rwunlock(&environ_rwmtx); + return res; } @@ -1555,7 +1555,7 @@ int erts_sys_getenv__(char *key, char *value, size_t *size) { int res; - char *orig_value = getenv(key); + char *orig_value = get_env(get_bid(current_process()), key); if (!orig_value) res = -1; else { @@ -1569,6 +1569,7 @@ erts_sys_getenv__(char *key, char *value, size_t *size) sys_memcpy((void *) value, (void *) orig_value, len+1); res = 0; } + free_buf((union SIGNAL **)&orig_value); } return res; } -- cgit v1.2.3