Diff between b43a79d0568214c77dc825ce475c4e2cd052858a and 36d674036359a8e30546bd7799fca87fb903d181

Changed Files

File Additions Deletions Status
client/main.c +17 -6 modified

Full Patch

diff --git a/client/main.c b/client/main.c
index 774c0cd..ae8aa92 100644
--- a/client/main.c
+++ b/client/main.c
@@ -60,6 +60,8 @@ static GDBusProxy *default_ctrl;
 static GList *ctrl_list;
 static GList *dev_list;
 
+static guint input = 0;
+
 static const char * const agent_arguments[] = {
 	"on",
 	"off",
@@ -1386,11 +1388,20 @@ static gboolean signal_handler(GIOChannel *channel, GIOCondition condition,
 
 	switch (si.ssi_signo) {
 	case SIGINT:
-		rl_replace_line("", 0);
-		rl_crlf();
-		rl_on_new_line();
-		rl_redisplay();
-		break;
+		if (input) {
+			rl_replace_line("", 0);
+			rl_crlf();
+			rl_on_new_line();
+			rl_redisplay();
+			break;
+		}
+
+		/*
+		 * If input was not yet setup up that means signal was received
+		 * while daemon was not yet running. Since user is not able
+		 * to terminate client by CTRL-D or typing exit treat this as
+		 * exit and fall through.
+		 */
 	case SIGTERM:
 		if (__terminated == 0) {
 			rl_replace_line("", 0);
@@ -1476,7 +1487,7 @@ int main(int argc, char *argv[])
 	GOptionContext *context;
 	GError *error = NULL;
 	GDBusClient *client;
-	guint signal, input;
+	guint signal;
 
 	context = g_option_context_new(NULL);
 	g_option_context_add_main_entries(context, options, NULL);