]> git.tdb.fi Git - gldbg.git/blobdiff - source/commandinterpreter.cpp
Prompt to terminate target process in exit command if it's still running
[gldbg.git] / source / commandinterpreter.cpp
index 9660aaa0ec8940487feae23a8c1aa74258d8fd9e..abc9dda60b07bc83d5125eac1612f8096d5e25eb 100644 (file)
@@ -6,6 +6,7 @@ Distributed under the GPL
 */
 
 #include <signal.h>
+#include <readline/readline.h>
 #include <msp/core/except.h>
 #include <msp/io/file.h>
 #include <msp/io/print.h>
@@ -155,7 +156,20 @@ void CommandInterpreter::cmd_kill(const string &)
 
 void CommandInterpreter::cmd_exit(const string &)
 {
-       gldbg.quit();
+       if(gldbg.get_process().get_state()!=Process::INACTIVE)
+       {
+               IO::print("Program is still running.  Kill it?\n");
+               char *answer = readline("[y/n] ");
+               if(answer[0]=='y')
+               {
+                       gldbg.get_process().kill();
+                       gldbg.quit(true);
+               }
+               else
+                       IO::print("Not confirmed.\n");
+       }
+       else
+               gldbg.quit(false);
 }
 
 void CommandInterpreter::cmd_trace(const string &args)