From 47eaf963e31dca8e82d6d9c9454c000528fe5fa7 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Wed, 4 May 2022 09:20:01 +0200 Subject: [PATCH] nmcli: be less insistant on exiting when readline() gets no input When the input ends, we indeed eventually want to shut down. Nevertheless, it might be that we terminated the input *because* we're already shutting down and want do do our cleanup. Let's not take the shortcut to nmc_exit() in case the main loop is no longer running. This doesn't affect existing uses of nmc_readline(), but will be useful in a future patch. --- src/nmcli/common.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nmcli/common.c b/src/nmcli/common.c index 710914e211..fa6d1caad8 100644 --- a/src/nmcli/common.c +++ b/src/nmcli/common.c @@ -929,7 +929,8 @@ read_again: } } else if (!rl_string) { /* Ctrl-D, exit */ - nmc_exit(); + if (g_main_loop_is_running(loop)) + nmc_exit(); } /* Return NULL, not empty string */