packer-cn/background_check.go

23 lines
413 B
Go
Raw Normal View History

// +build !openbsd
package main
import (
2019-09-19 11:55:52 -04:00
"fmt"
"github.com/shirou/gopsutil/process"
)
func checkProcess(currentPID int) (bool, error) {
2019-09-19 11:55:52 -04:00
myProc, err := process.NewProcess(int32(currentPID))
if err != nil {
2019-09-19 11:57:50 -04:00
return false, fmt.Errorf("Process check error: %s", err)
}
bg, err := myProc.Background()
if err != nil {
return bg, fmt.Errorf("Process background check error: %s", err)
2019-09-19 11:55:52 -04:00
}
return bg, nil
}