Skip to content

Commit

Permalink
Forward SIGTERM and handle that as an interrupt
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Dec 8, 2016
1 parent 9c80c82 commit e9c35ea
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 10 deletions.
3 changes: 2 additions & 1 deletion commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,8 @@ func makeShutdownCh() <-chan struct{} {
resultCh := make(chan struct{})

signalCh := make(chan os.Signal, 4)
signal.Notify(signalCh, interruptSignals...)
signal.Notify(signalCh, ignoreSignals...)
signal.Notify(signalCh, forwardSignals...)
go func() {
for {
<-signalCh
Expand Down
3 changes: 2 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ func realMain() int {
wrapConfig.Handler = panicHandler(logTempFile)
wrapConfig.Writer = io.MultiWriter(logTempFile, logWriter)
wrapConfig.Stdout = outW
wrapConfig.IgnoreSignals = interruptSignals
wrapConfig.IgnoreSignals = ignoreSignals
wrapConfig.ForwardSignals = forwardSignals
exitStatus, err := panicwrap.Wrap(&wrapConfig)
if err != nil {
fmt.Fprintf(os.Stderr, "Couldn't start Terraform: %s", err)
Expand Down
6 changes: 2 additions & 4 deletions signal_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,5 @@ import (
"syscall"
)

var interruptSignals []os.Signal = []os.Signal{
os.Interrupt,
syscall.SIGTERM,
}
var ignoreSignals = []os.Signal{os.Interrupt}
var forwardSignals = []os.Signal{syscall.SIGTERM}
3 changes: 2 additions & 1 deletion signal_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ import (
"os"
)

var interruptSignals []os.Signal = []os.Signal{os.Interrupt}
var ignoreSignals = []os.Signal{os.Interrupt}
var forwardSignals []os.Signal
14 changes: 14 additions & 0 deletions vendor/github.com/mitchellh/panicwrap/panicwrap.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions vendor/vendor.json
Original file line number Diff line number Diff line change
Expand Up @@ -2079,10 +2079,10 @@
"revision": "314aad379a39f6ad5bcca278e6757d9abbb3a52e"
},
{
"checksumSHA1": "kTntIB9SdU1NsCqKwDkUr99qaj0=",
"checksumSHA1": "AykrbOR+O+Yp6DQHfwe31+iyFi0=",
"path": "github.com/mitchellh/panicwrap",
"revision": "fde185d0dfb5ecac6e6b201e8855da798ebcd76f",
"revisionTime": "2016-11-21T18:34:54Z"
"revision": "ba9e1a65e0f7975f055d50a2c0201c50d941c24c",
"revisionTime": "2016-12-08T17:03:02Z"
},
{
"path": "github.com/mitchellh/prefixedio",
Expand Down

0 comments on commit e9c35ea

Please sign in to comment.