Restart process should use the current process' pid (#7373)

This fixes varying pids for server-respawns. And avoids duplicate process
creating multiple pids when the server restart signal is triggered with
service restart enabled.

Fixes #7350
This commit is contained in:
Praveen raj Mani 2019-03-21 10:50:30 +05:30 committed by kannappanr
parent 8e1e701d35
commit 89e45d0695
1 changed files with 4 additions and 5 deletions

View File

@ -19,6 +19,7 @@ package cmd
import (
"os"
"os/exec"
"syscall"
)
// Type of service signals currently supported.
@ -56,9 +57,7 @@ func restartProcess() error {
return err
}
// Pass on the environment and replace the old count key with the new one.
cmd := exec.Command(argv0, os.Args[1:]...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
return cmd.Start()
// Invokes the execve system call.
// Re-uses the same pid. This preserves the pid over multiple server-respawns.
return syscall.Exec(argv0, os.Args, os.Environ())
}