changeset 214:2d60aa9bde0a

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-----
author mpm@selenic.com
date Wed, 01 Jun 2005 13:04:13 -0800
parents d2172916ef6c
children 9ff5a78d0c45
files mercurial/commands.py
diffstat 1 files changed, 10 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/mercurial/commands.py	Wed Jun 01 11:48:34 2005 -0800
+++ b/mercurial/commands.py	Wed Jun 01 13:04:13 2005 -0800
@@ -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 @@
 
     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 @@
     # 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 @@
 
     try:
         d()
+    except SignalInterrupt:
+        u.warn("killed!\n")
     except KeyboardInterrupt:
         u.warn("interrupted!\n")
     except TypeError, inst: