improve genv.Remove/gproc.Kill

This commit is contained in:
John
2020-01-10 22:32:07 +08:00
parent ca546fc30b
commit afadbc6621
2 changed files with 14 additions and 4 deletions

View File

@ -60,7 +60,14 @@ func Build(m map[string]string) []string {
return array
}
// Remove deletes a single environment variable.
func Remove(key string) error {
return os.Unsetenv(key)
// Remove deletes one or more environment variables.
func Remove(key ...string) error {
var err error
for _, v := range key {
err = os.Unsetenv(v)
if err != nil {
return err
}
}
return nil
}

View File

@ -11,6 +11,7 @@ import (
"fmt"
"os"
"os/exec"
"runtime"
"strings"
)
@ -115,7 +116,9 @@ func (p *Process) Kill() error {
if p.Manager != nil {
p.Manager.processes.Remove(p.Pid())
}
p.Process.Release()
if runtime.GOOS != "windows" {
p.Process.Release()
}
p.Process.Wait()
return nil
} else {