diff options
author | Toby Allen <tobyallen@toflidium.com> | 2019-07-20 17:44:54 +0100 |
---|---|---|
committer | Matt Holt <mholt@users.noreply.github.com> | 2019-07-20 10:44:54 -0600 |
commit | b855e661700fa8f9176f29c3c5b1cebd4cc09351 (patch) | |
tree | b88fcd62af8ba934182b9cdc065b0fe6fb7d9ee2 /cmd/commands.go | |
parent | 0d3f99e85a089a6a772ae38f426b5cd5f2f4583f (diff) |
Force quit on Windows with taskkill /f (#2670)
* Force quit /f on windows, also check for processname '.exe' on windows.
* Remove unneeded spaces
* fix tabs
* go fmt tabs
* Return consistent appname which always includes .exe
* Change func name
Diffstat (limited to 'cmd/commands.go')
-rw-r--r-- | cmd/commands.go | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/cmd/commands.go b/cmd/commands.go index 072c1d4..e63e2d5 100644 --- a/cmd/commands.go +++ b/cmd/commands.go @@ -27,7 +27,7 @@ import ( "net/http" "os" "os/exec" - "path/filepath" + "strings" "github.com/caddyserver/caddy/v2" @@ -203,14 +203,14 @@ func cmdStop() (int, error) { if err != nil { return caddy.ExitCodeFailedStartup, fmt.Errorf("listing processes: %v", err) } - thisProcName := filepath.Base(os.Args[0]) + thisProcName := getProcessName() var found bool for _, p := range processList { // the process we're looking for should have the same name but different PID if p.Executable() == thisProcName && p.Pid() != os.Getpid() { found = true fmt.Printf("pid=%d\n", p.Pid()) - fmt.Printf("Graceful stop...") + if err := gracefullyStopProcess(p.Pid()); err != nil { return caddy.ExitCodeFailedStartup, err } |