From 2b822161f0295483737fa501dba84dfafea77af8 Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Wed, 25 May 2022 12:15:07 +0200 Subject: [PATCH] agnhost: fix sigterm shutdown --- test/images/agnhost/VERSION | 2 +- test/images/agnhost/netexec/netexec.go | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/test/images/agnhost/VERSION b/test/images/agnhost/VERSION index 555eb8e4974..23f36200812 100644 --- a/test/images/agnhost/VERSION +++ b/test/images/agnhost/VERSION @@ -1 +1 @@ -2.38 +2.39 diff --git a/test/images/agnhost/netexec/netexec.go b/test/images/agnhost/netexec/netexec.go index 582a16e8eba..f1510a0fcc4 100644 --- a/test/images/agnhost/netexec/netexec.go +++ b/test/images/agnhost/netexec/netexec.go @@ -175,14 +175,14 @@ func main(cmd *cobra.Command, args []string) { close(sigTermReceived) }() - if delayShutdown > 0 { - go func() { - <-sigTermReceived + go func() { + <-sigTermReceived + if delayShutdown > 0 { log.Printf("Sleeping %d seconds before terminating...", delayShutdown) time.Sleep(time.Duration(delayShutdown) * time.Second) - os.Exit(0) - }() - } + } + os.Exit(0) + }() if httpOverride != "" { mux := http.NewServeMux()