From c5e533b131d8c8f1801a9b1cc15f68241f746833 Mon Sep 17 00:00:00 2001 From: polinasok <51177946+polinasok@users.noreply.github.com> Date: Wed, 21 Jul 2021 07:43:06 -0700 Subject: [PATCH] Treat SIGTERM as a server disconnect signal (#2580) Co-authored-by: Polina Sokolova --- cmd/dlv/cmds/commands.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/dlv/cmds/commands.go b/cmd/dlv/cmds/commands.go index c5523694..3f2a2f1a 100644 --- a/cmd/dlv/cmds/commands.go +++ b/cmd/dlv/cmds/commands.go @@ -690,14 +690,14 @@ func connectCmd(cmd *cobra.Command, args []string) { } // waitForDisconnectSignal is a blocking function that waits for either -// a SIGINT (Ctrl-C) signal from the OS or for disconnectChan to be closed -// by the server when the client disconnects. +// a SIGINT (Ctrl-C) or SIGTERM (kill -15) OS signal or for disconnectChan +// to be closed by the server when the client disconnects. // Note that in headless mode, the debugged process is foregrounded // (to have control of the tty for debugging interactive programs), // so SIGINT gets sent to the debuggee and not to delve. func waitForDisconnectSignal(disconnectChan chan struct{}) { ch := make(chan os.Signal, 1) - signal.Notify(ch, syscall.SIGINT) + signal.Notify(ch, syscall.SIGINT, syscall.SIGTERM) if runtime.GOOS == "windows" { // On windows Ctrl-C sent to inferior process is delivered // as SIGINT to delve. Ignore it instead of stopping the server