2023-03-02 15:37:05 -05:00
|
|
|
// Copyright (c) HashiCorp, Inc.
|
2023-08-10 18:53:29 -04:00
|
|
|
// SPDX-License-Identifier: BUSL-1.1
|
2023-03-02 15:37:05 -05:00
|
|
|
|
2021-09-02 06:15:13 -04:00
|
|
|
//go:build !openbsd
|
2019-09-18 13:51:57 -04:00
|
|
|
// +build !openbsd
|
|
|
|
|
|
|
|
|
|
package main
|
|
|
|
|
|
|
|
|
|
import (
|
2019-09-19 11:55:52 -04:00
|
|
|
"fmt"
|
|
|
|
|
|
2023-05-25 15:45:13 -04:00
|
|
|
"github.com/shirou/gopsutil/v3/process"
|
2019-09-18 13:51:57 -04:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
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
|
|
|
}
|
2019-09-18 13:51:57 -04:00
|
|
|
|
|
|
|
|
return bg, nil
|
|
|
|
|
}
|