summaryrefslogtreecommitdiff
path: root/cmd/proc_windows.go
diff options
context:
space:
mode:
authorToby Allen <tobyallen@toflidium.com>2019-07-20 17:44:54 +0100
committerMatt Holt <mholt@users.noreply.github.com>2019-07-20 10:44:54 -0600
commitb855e661700fa8f9176f29c3c5b1cebd4cc09351 (patch)
treeb88fcd62af8ba934182b9cdc065b0fe6fb7d9ee2 /cmd/proc_windows.go
parent0d3f99e85a089a6a772ae38f426b5cd5f2f4583f (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/proc_windows.go')
-rw-r--r--cmd/proc_windows.go17
1 files changed, 16 insertions, 1 deletions
diff --git a/cmd/proc_windows.go b/cmd/proc_windows.go
index 27fbdeb..d333948 100644
--- a/cmd/proc_windows.go
+++ b/cmd/proc_windows.go
@@ -16,14 +16,29 @@ package caddycmd
import (
"fmt"
+ "os"
"os/exec"
+ "path/filepath"
"strconv"
)
func gracefullyStopProcess(pid int) error {
- cmd := exec.Command("taskkill", "/pid", strconv.Itoa(pid))
+ fmt.Printf("Forceful Stop...")
+ // process on windows will not stop unless forced with /f
+ cmd := exec.Command("taskkill", "/pid", strconv.Itoa(pid), "/f")
if err := cmd.Run(); err != nil {
return fmt.Errorf("taskkill: %v", err)
}
return nil
}
+
+// On Windows the app name passed in os.Args[0] will match how
+// caddy was started eg will match caddy or caddy.exe.
+// So return appname with .exe for consistency
+func getProcessName() string {
+ base := filepath.Base(os.Args[0])
+ if filepath.Ext(base) == "" {
+ return base + ".exe"
+ }
+ return base
+}