os: implement and smoketest os.Clearenv

This commit is contained in:
Dan Kegel
2021-12-11 11:53:02 -08:00
committed by Ron Evans
parent e4f2b9c003
commit 51fc78c100
4 changed files with 49 additions and 0 deletions
+11
View File
@@ -151,6 +151,17 @@ func Unsetenv(key string) (err error) {
return
}
func Clearenv() {
for _, s := range Environ() {
for j := 0; j < len(s); j++ {
if s[j] == '=' {
Unsetenv(s[0:j])
break
}
}
}
}
func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
addr := libc_mmap(nil, uintptr(length), int32(prot), int32(flags), int32(fd), uintptr(offset))
if addr == unsafe.Pointer(^uintptr(0)) {
+5
View File
@@ -77,6 +77,11 @@ func Unsetenv(key string) (err error) {
return ENOSYS
}
func Clearenv() (err error) {
// stub for now
return ENOSYS
}
func Environ() []string {
env := runtime_envs()
envCopy := make([]string, len(env))