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) } }