From 2b27923fc810deb0ff6684f2be6597ce3a137f15 Mon Sep 17 00:00:00 2001 From: Guillaume Beraudo <guillaume.beraudo@belledonne-communications.com> Date: Fri, 19 Jul 2013 15:33:17 +0200 Subject: [PATCH] Quit on ctrl+d --- daemon/daemon.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/daemon/daemon.cc b/daemon/daemon.cc index 2af8da2be2..84201448bc 100644 --- a/daemon/daemon.cc +++ b/daemon/daemon.cc @@ -706,6 +706,7 @@ char *Daemon::readLine(const char *prompt) { #ifdef HAVE_READLINE return readline(prompt); #else + if (cin.eof()) return NULL; cout << prompt; char *buff = (char *) malloc(sLineSize); cin.getline(buff, sLineSize); @@ -735,6 +736,10 @@ int Daemon::run() { if (mServerFd == -1 && ret != NULL) { free(ret); } + if (!ret && mRunning) { + mRunning = false; // ctrl+d + cout << "Quitting..." << endl; + } } stopThread(); return 0; -- GitLab