From 8dac26b2bbb0b8bed309c2d66b347b88ed3a416a Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 2 Jan 2022 05:28:37 +0400 Subject: [PATCH] Removed check for pgrep. IsProcessUP replaced by GetProcessPIDs. --- main.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/main.go b/main.go index 04ecc11..c5977b7 100644 --- a/main.go +++ b/main.go @@ -6,7 +6,6 @@ import ( . "httpprocwatchd/prog" "log" "os" - "os/exec" "os/signal" "syscall" ) @@ -58,10 +57,6 @@ func main() { return } - if _, err := exec.LookPath("pgrep"); err != nil { - log.Fatalln(ErrPgrepNotFound) - } - conf, err := LoadConfiguration(oConfigPath) if err != nil { log.Fatalf("Cannot load configuration file: %s\n", err) @@ -89,16 +84,16 @@ func main() { // If we modified a list then let's look for a running program and // send SIGHUP for it to reload a list. if oAddProcess != "" || oRemoveProcess != "" { - isup, pid, _ := IsProcessUp("httpprocwatchd") - if isup && pid != nil && len(pid) > 1 { + pids, _ := GetProcessPIDs("httpprocwatchd") + if pids != nil && len(pids) > 1 { var trgt_pid int - if pid[0] == os.Getpid() { - trgt_pid = pid[1] + if pids[0] == os.Getpid() { + trgt_pid = pids[1] } else { - trgt_pid = pid[0] + trgt_pid = pids[0] } - proc, err := os.FindProcess(trgt_pid) - if err == nil { + + if proc, err := os.FindProcess(trgt_pid); err == nil { proc.Signal(syscall.SIGHUP) } }