Rev 2428: Second sigquit goes through to the default handler in http://sourcefrog.net/bzr/breakin
Martin Pool
mbp at sourcefrog.net
Tue Apr 17 08:32:23 BST 2007
At http://sourcefrog.net/bzr/breakin
------------------------------------------------------------
revno: 2428
revision-id: mbp at sourcefrog.net-20070417073222-l20nvpvkfr8ak12d
parent: mbp at sourcefrog.net-20070417065755-lgvnd360eqfs8cfz
committer: Martin Pool <mbp at sourcefrog.net>
branch nick: breakin
timestamp: Tue 2007-04-17 17:32:22 +1000
message:
Second sigquit goes through to the default handler
modified:
bzrlib/breakin.py breakin.py-20070417043829-so46nevf978u713k-1
bzrlib/tests/blackbox/test_debug.py test_debug.py-20061026142942-q76cgg41785b3mdk-1
=== modified file 'bzrlib/breakin.py'
--- a/bzrlib/breakin.py 2007-04-17 06:57:55 +0000
+++ b/bzrlib/breakin.py 2007-04-17 07:32:22 +0000
@@ -14,15 +14,21 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+import signal
+
def _debug(signal_number, interrupted_frame):
import pdb
import sys
sys.stderr.write("** SIGQUIT received, entering debugger\n"
- "** Type 'c' to continue or 'q' to stop the process\n")
+ "** Type 'c' to continue or 'q' to stop the process\n"
+ "** Or SIGQUIT again to quit (and possibly dump core)\n"
+ )
+ signal.signal(signal.SIGQUIT, signal.SIG_DFL)
pdb.set_trace()
+ signal.signal(signal.SIGQUIT, _debug)
+
def hook_sigquit():
# when sigquit (C-\) is received go into pdb
# XXX: is this meaningful on Windows?
- import signal
signal.signal(signal.SIGQUIT, _debug)
=== modified file 'bzrlib/tests/blackbox/test_debug.py'
--- a/bzrlib/tests/blackbox/test_debug.py 2007-04-17 04:39:12 +0000
+++ b/bzrlib/tests/blackbox/test_debug.py 2007-04-17 07:32:22 +0000
@@ -47,10 +47,24 @@
if sys.platform == 'win32':
raise TestSkipped('breakin signal not tested on win32')
proc = self.start_bzr_subprocess(['serve'])
+ # wait for it to get started
time.sleep(.5)
+ # first sigquit pops into debugger
os.kill(proc.pid, signal.SIGQUIT)
+ proc.stdin.write("q\n")
time.sleep(.5)
- proc.stdin.write('q\n')
- err = proc.stderr.read()
+ err = proc.stderr.readline()
self.assertContainsRe(err, r'entering debugger')
+
+ def test_breakin_harder(self):
+ if sys.platform == 'win32':
+ raise TestSkipped('breakin signal not tested on win32')
+ proc = self.start_bzr_subprocess(['serve'])
+ # wait for it to get started
+ time.sleep(.5)
+ # another hit gives the default behaviour of terminating it
+ os.kill(proc.pid, signal.SIGQUIT)
+ # wait for it to go into pdb
+ time.sleep(.5)
+ os.kill(proc.pid, signal.SIGQUIT)
proc.wait()
More information about the bazaar-commits
mailing list