mirror of
https://gitee.com/johng/gf
synced 2026-06-06 16:21:40 +08:00
improve genv.Remove/gproc.Kill
This commit is contained in:
@ -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
|
||||
}
|
||||
|
||||
@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user