aboutsummaryrefslogtreecommitdiffstats
path: root/erts/emulator/sys
diff options
context:
space:
mode:
authorLukas Larsson <[email protected]>2014-02-23 16:48:17 +0100
committerLukas Larsson <[email protected]>2014-02-24 15:15:55 +0100
commit8084f0f9797daf83bf6da698e5e1e5784c11601b (patch)
tree63728357350f2c528df28bbccc6e03acfca2dc23 /erts/emulator/sys
parent67c5954250d8a07e3b6ddb9851f33a16fd631a0f (diff)
downloadotp-8084f0f9797daf83bf6da698e5e1e5784c11601b.tar.gz
otp-8084f0f9797daf83bf6da698e5e1e5784c11601b.tar.bz2
otp-8084f0f9797daf83bf6da698e5e1e5784c11601b.zip
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.
Diffstat (limited to 'erts/emulator/sys')
-rw-r--r--erts/emulator/sys/ose/sys.c33
1 files changed, 17 insertions, 16 deletions
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;
}