Skip to content

Commit

Permalink
Only cleanup temporary file after run is over
Browse files Browse the repository at this point in the history
Mac apparently sends SIGKILL to processes spawned by a process that no
longer exists on disk! ... or something like that.
  • Loading branch information
mholt committed Apr 23, 2020
1 parent 7e4f9a0 commit 68d27a0
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions cmd/xcaddy/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import (
"path/filepath"
"runtime"
"strings"
"time"

"github.com/caddyserver/xcaddy"
)
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 68d27a0

Please sign in to comment.