sonic-telemetry icon indicating copy to clipboard operation
sonic-telemetry copied to clipboard

Fix Ctrl+C to terminate dialout_client_cli

Open MuLinForest opened this issue 5 years ago • 5 comments

Ctrl+C cannot terminate dialout_client_cli until dialout_client received the Redis Pub/Sub message.

The reason is that the code to check the ctx.Done() is behind the code to receive message.

Therefore, I move the checking code in order to terminate the program even if there is no Redis Pub/Sub message received.

MuLinForest avatar Jan 22 '20 03:01 MuLinForest

retest this please.

renukamanavalan avatar Jan 25 '20 01:01 renukamanavalan

retest this please.

renukamanavalan avatar Jan 27 '20 17:01 renukamanavalan

Retest this please

jleveque avatar Jan 27 '20 20:01 jleveque

retest this please

gord1306 avatar Feb 04 '20 08:02 gord1306

I noticed this issue as well but I thought this would fix it instead:

diff --git a/dialout/dialout_client_cli/dialout_client_cli.go b/dialout/dialout_client_cli/dialout_client_cli.go
index d8d9014..a5df70b 100644
--- a/dialout/dialout_client_cli/dialout_client_cli.go
+++ b/dialout/dialout_client_cli/dialout_client_cli.go
@@ -34,7 +34,7 @@ func main() {
        flag.Parse()
        ctx, cancel := context.WithCancel(context.Background())
        // Terminate on Ctrl+C
-       go func() {
+       defer func() {
                c := make(chan os.Signal, 1)
                signal.Notify(c, os.Interrupt)
                <-c

seiferteric avatar Jun 04 '20 17:06 seiferteric