X-Git-Url: https://git.sthu.org/?p=pygdb.git;a=blobdiff_plain;f=DbgTerminal.py;h=21aa1c42d790f4b1bc230be0e51c54715b627466;hp=89659d035628a9fe7a450bffc9e603ff905eceb7;hb=054679cd2c3372717bf7982407e2453428193581;hpb=1094f7f4581a9c0074294004bbd8c934593a54d5 diff --git a/DbgTerminal.py b/DbgTerminal.py index 89659d0..21aa1c4 100644 --- a/DbgTerminal.py +++ b/DbgTerminal.py @@ -5,6 +5,7 @@ __author__ = "shuber" import gtk +import os import pango import pty import string @@ -21,12 +22,18 @@ class DbgTerminal (vte.Terminal): isactive = True lastrow = 0 history = [] + childpid = None - def __init__(self, clientCmd): + def __init__(self, clientCmd, exitcb=None): vte.Terminal.__init__(self) + def onChildExited(): + self.childpid = None + if exitcb != None: + exitcb() + #Start debugger self.clientCmd = clientCmd #Open pseudo-terminal where to-be-debugged process reads/writes to @@ -34,7 +41,7 @@ class DbgTerminal (vte.Terminal): #Set up terminal window and initialize debugger self.connect("cursor-moved", self.contents_changed) - self.connect("child-exited", lambda *w: gtk.main_quit()) + self.connect("child-exited", lambda *w: onChildExited()) #font description fontdesc = pango.FontDescription("monospace 9") @@ -42,10 +49,17 @@ class DbgTerminal (vte.Terminal): def initialize(self): - self.fork_command( self.getCommand(), self.getArgv()) + self.childpid = self.fork_command( self.getCommand(), self.getArgv()) self.setPty(self.client_ptyslave) self.waitForActivation() + def stopDbg(self): + + if self.childpid != None: + os.kill(self.childpid, 15); + self.childpid = None + + def contents_changed(self, term): c,r = term.get_cursor_position()