github.com/hashicorp/packer@v1.14.3/background_check.go (about) 1 // Copyright (c) HashiCorp, Inc. 2 // SPDX-License-Identifier: BUSL-1.1 3 4 //go:build !openbsd 5 // +build !openbsd 6 7 package main 8 9 import ( 10 "fmt" 11 12 "github.com/shirou/gopsutil/v3/process" 13 ) 14 15 func checkProcess(currentPID int) (bool, error) { 16 myProc, err := process.NewProcess(int32(currentPID)) 17 if err != nil { 18 return false, fmt.Errorf("Process check error: %s", err) 19 } 20 bg, err := myProc.Background() 21 if err != nil { 22 return bg, fmt.Errorf("Process background check error: %s", err) 23 } 24 25 return bg, nil 26 }