From 51fc78c100ea055bdd2eccf0527472c2f9b33ed0 Mon Sep 17 00:00:00 2001 From: Dan Kegel Date: Sat, 11 Dec 2021 11:53:02 -0800 Subject: os: implement and smoketest os.Clearenv --- src/syscall/syscall_libc.go | 11 +++++++++++ src/syscall/syscall_nonhosted.go | 5 +++++ 2 files changed, 16 insertions(+) (limited to 'src/syscall') diff --git a/src/syscall/syscall_libc.go b/src/syscall/syscall_libc.go index 05df16fd7..25c778650 100644 --- a/src/syscall/syscall_libc.go +++ b/src/syscall/syscall_libc.go @@ -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)) { diff --git a/src/syscall/syscall_nonhosted.go b/src/syscall/syscall_nonhosted.go index 9e5b70fdc..be1b32c7b 100644 --- a/src/syscall/syscall_nonhosted.go +++ b/src/syscall/syscall_nonhosted.go @@ -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)) -- cgit v1.2.3