From 84c930a07894e30804469c32d84377b15868bfce Mon Sep 17 00:00:00 2001 From: cinap_lenrek Date: Mon, 3 Dec 2012 06:44:30 +0100 Subject: ape: fix putenv() writing /env in putenv() doesnt work. exec will create new enviroment anyway. we have to modify environ array! --- sys/src/ape/lib/ap/plan9/_envsetup.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'sys/src/ape/lib/ap/plan9') diff --git a/sys/src/ape/lib/ap/plan9/_envsetup.c b/sys/src/ape/lib/ap/plan9/_envsetup.c index 6a4f4204e..11f53dc81 100644 --- a/sys/src/ape/lib/ap/plan9/_envsetup.c +++ b/sys/src/ape/lib/ap/plan9/_envsetup.c @@ -45,11 +45,8 @@ _envsetup(void) fdinited = 0; cnt = 0; dfd = _OPEN("/env", 0); - if(dfd < 0) { - static char **emptyenvp = 0; - environ = emptyenvp; - return; - } + if(dfd < 0) + goto done; psize = Envhunk; ps = p = malloc(psize); nd = _dirreadall(dfd, &d9a); @@ -92,6 +89,7 @@ _envsetup(void) free(d9a); if(!fdinited) _fdinit(0, 0); +done: environ = pp = malloc((1+cnt)*sizeof(char *)); p = ps; for(i = 0; i < cnt; i++) { -- cgit v1.2.3