aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/init.go
diff options
context:
space:
mode:
Diffstat (limited to 'container/init.go')
-rw-r--r--container/init.go23
1 files changed, 17 insertions, 6 deletions
diff --git a/container/init.go b/container/init.go
index 4e2345b3..0f5edb19 100644
--- a/container/init.go
+++ b/container/init.go
@@ -390,7 +390,8 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
// handle signals to dump withheld messages
sig := make(chan os.Signal, 2)
- k.notify(sig, os.Interrupt, CancelSignal)
+ k.notify(sig, CancelSignal,
+ os.Interrupt, SIGTERM, SIGQUIT)
// closed after residualProcessTimeout has elapsed after initial process death
timeout := make(chan struct{})
@@ -399,18 +400,28 @@ func initEntrypoint(k syscallDispatcher, msg message.Msg) {
for {
select {
case s := <-sig:
- if msg.Resume() {
- msg.Verbosef("%s after process start", s.String())
- } else {
- msg.Verbosef("got %s", s.String())
- }
if s == CancelSignal && params.ForwardCancel && cmd.Process != nil {
+ msg.Resume()
msg.Verbose("forwarding context cancellation")
if err := k.signal(cmd, os.Interrupt); err != nil {
k.printf(msg, "cannot forward cancellation: %v", err)
}
continue
}
+
+ if s == SIGTERM || s == SIGQUIT {
+ msg.Verbosef("got %s, forwarding to initial process", s.String())
+ if err := k.signal(cmd, s); err != nil {
+ k.printf(msg, "cannot forward signal: %v", err)
+ }
+ continue
+ }
+
+ if msg.Resume() {
+ msg.Verbosef("%s after process start", s.String())
+ } else {
+ msg.Verbosef("got %s", s.String())
+ }
msg.BeforeExit()
k.exit(0)