From aa8b9164a377edf74e7f990ed09ef641b223b695 Mon Sep 17 00:00:00 2001 From: Megan Marsh Date: Thu, 19 Sep 2019 08:55:52 -0700 Subject: [PATCH] check for and handle errors --- background_check.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/background_check.go b/background_check.go index c86602e68..2458ad6ed 100644 --- a/background_check.go +++ b/background_check.go @@ -3,11 +3,16 @@ package main import ( + "fmt" + "github.com/shirou/gopsutil/process" ) func checkProcess(currentPID int) (bool, error) { - myProc, _ := process.NewProcess(int32(currentPID)) + myProc, err := process.NewProcess(int32(currentPID)) + if err != nil { + return false, fmt.Errorf("Error figuring out Packer process info") + } bg, _ := myProc.Background() return bg, nil