1
0

Removed check for pgrep. IsProcessUP replaced by GetProcessPIDs.

This commit is contained in:
Alexander Andreev 2022-01-02 05:28:37 +04:00
parent 4837a8b66e
commit 8dac26b2bb
Signed by: Arav
GPG Key ID: 1327FE8A374CC86F

19
main.go
View File

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