Removed check for pgrep. IsProcessUP replaced by GetProcessPIDs.
This commit is contained in:
parent
4837a8b66e
commit
8dac26b2bb
19
main.go
19
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)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user