From 68d27a04011d55258148097c338d39c90f72cb9a Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 23 Apr 2020 15:04:06 -0600 Subject: [PATCH] Only cleanup temporary file after run is over Mac apparently sends SIGKILL to processes spawned by a process that no longer exists on disk! ... or something like that. --- cmd/xcaddy/main.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/cmd/xcaddy/main.go b/cmd/xcaddy/main.go index 71fbb46..404eb65 100644 --- a/cmd/xcaddy/main.go +++ b/cmd/xcaddy/main.go @@ -24,7 +24,6 @@ import ( "path/filepath" "runtime" "strings" - "time" "github.com/caddyserver/xcaddy" ) @@ -203,17 +202,11 @@ func runDev(ctx context.Context, args []string) error { if err != nil { return err } - - cleanup := func() { + defer func() { err = os.Remove(binOutput) if err != nil && !os.IsNotExist(err) { log.Printf("[ERROR] Deleting temporary binary %s: %v", binOutput, err) } - } - defer cleanup() - go func() { - time.Sleep(5 * time.Second) - cleanup() }() return cmd.Wait()