Skip to content

Commit

Permalink
First interrupt before killing a daemon on shutdown
Browse files Browse the repository at this point in the history
  • Loading branch information
bartjkdp committed Nov 30, 2019
1 parent 45e41bb commit a467bf4
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions shell/shell.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@ import (
"io"
"os"
"os/exec"
"runtime"
"sync"
"time"

"github.com/cortesi/termlog"
)
Expand Down Expand Up @@ -157,6 +159,22 @@ func (e *Executor) Signal(sig os.Signal) error {
}

func (e *Executor) Stop() error {
// Windows does not support Interrupt
if runtime.GOOS == "windows" {
return e.Signal(os.Kill)
}

err := e.Signal(os.Interrupt)
if err != nil {
return err
}

time.Sleep(2 * time.Second)

if !e.Running() {
return nil
}

return e.Signal(os.Kill)
}

Expand Down

0 comments on commit a467bf4

Please sign in to comment.