catch TERM signal in command processor

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

catch TERM signal in command processor

This keeps kill from interrupting a transaction without cleanup.

manifest hash: c50091696a3396dfed5c3168bd9e0d94c457a04b
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.0 (GNU/Linux)

iD8DBQFCniLNywK+sNU5EO8RAvepAKCCnEX7vPheIyOu2IvV6dDahdFMWACeMih6
E2R3rA/MGACxG9HpSNH6lak=
=HR1s
-----END PGP SIGNATURE-----
This commit is contained in:
mpm@selenic.com 2005-06-01 13:04:13 -08:00
parent f1f83067d7
commit dd6fb288d8

View File

@ -1,4 +1,4 @@
import os, re, traceback, sys
import os, re, traceback, sys, signal
from mercurial import fancyopts, ui, hg
class UnknownCommand(Exception): pass
@ -159,6 +159,11 @@ def find(cmd):
raise UnknownCommand(cmd)
class SignalInterrupt(Exception): pass
def catchterm(*args):
raise SignalInterrupt
def dispatch(args):
options = {}
opts = [('v', 'verbose', None, 'verbose'),
@ -181,6 +186,8 @@ def dispatch(args):
# deal with unfound commands later
i = find(cmd)
signal.signal(signal.SIGTERM, catchterm)
cmdoptions = {}
args = fancyopts.fancyopts(args, i[1], cmdoptions, i[2])
@ -192,6 +199,8 @@ def dispatch(args):
try:
d()
except SignalInterrupt:
u.warn("killed!\n")
except KeyboardInterrupt:
u.warn("interrupted!\n")
except TypeError, inst: