~bzr-pqm/bzr/bzr.dev

« back to all changes in this revision

Viewing changes to bzrlib/breakin.py

  • Committer: Martin Pool
  • Date: 2007-04-24 04:51:31 UTC
  • mto: This revision was merged to the branch mainline in revision 2450.
  • Revision ID: mbp@sourcefrog.net-20070424045131-gyjo7l8oa99ndyrv
Add BZR_SIGQUIT_PDB=0 option to disable breakin.

Split tests for this into test_breakin, and make them a bit more robust.

Show diffs side-by-side

added added

removed removed

Lines of Context:
14
14
# along with this program; if not, write to the Free Software
15
15
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
16
16
 
 
17
import os
17
18
import signal
18
19
 
19
20
def _debug(signal_number, interrupted_frame):
23
24
            "** Type 'c' to continue or 'q' to stop the process\n"
24
25
            "** Or SIGQUIT again to quit (and possibly dump core)\n"
25
26
            )
 
27
    # restore default meaning so that you can kill the process by hitting it
 
28
    # twice
26
29
    signal.signal(signal.SIGQUIT, signal.SIG_DFL)
27
 
    pdb.set_trace()
28
 
    signal.signal(signal.SIGQUIT, _debug)
 
30
    try:
 
31
        pdb.set_trace()
 
32
    finally:
 
33
        signal.signal(signal.SIGQUIT, _debug)
29
34
 
30
35
 
31
36
def hook_sigquit():
32
37
    # when sigquit (C-\) is received go into pdb
33
38
    # XXX: is this meaningful on Windows?
 
39
    if os.environ.get('BZR_SIGQUIT_PDB', '1') == '0':
 
40
        return
34
41
    signal.signal(signal.SIGQUIT, _debug)