*/
#include <signal.h>
+#include <readline/readline.h>
#include <msp/core/except.h>
#include <msp/io/file.h>
#include <msp/io/print.h>
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)
close(fds[1]);
}
-void GlDbg::quit()
+void GlDbg::quit(bool force)
{
- if(process.get_state()!=Process::INACTIVE)
+ if(!force && process.get_state()!=Process::INACTIVE)
throw InvalidState("Program is still running");
exit(0);
}