##// END OF EJS Templates
catch TERM signal in command processor...
mpm@selenic.com -
r214:2d60aa9b default
parent child Browse files
Show More
@@ -1,4 +1,4 b''
1 import os, re, traceback, sys
1 import os, re, traceback, sys, signal
2 from mercurial import fancyopts, ui, hg
2 from mercurial import fancyopts, ui, hg
3
3
4 class UnknownCommand(Exception): pass
4 class UnknownCommand(Exception): pass
@@ -159,6 +159,11 b' def find(cmd):'
159
159
160 raise UnknownCommand(cmd)
160 raise UnknownCommand(cmd)
161
161
162 class SignalInterrupt(Exception): pass
163
164 def catchterm(*args):
165 raise SignalInterrupt
166
162 def dispatch(args):
167 def dispatch(args):
163 options = {}
168 options = {}
164 opts = [('v', 'verbose', None, 'verbose'),
169 opts = [('v', 'verbose', None, 'verbose'),
@@ -181,6 +186,8 b' def dispatch(args):'
181 # deal with unfound commands later
186 # deal with unfound commands later
182 i = find(cmd)
187 i = find(cmd)
183
188
189 signal.signal(signal.SIGTERM, catchterm)
190
184 cmdoptions = {}
191 cmdoptions = {}
185 args = fancyopts.fancyopts(args, i[1], cmdoptions, i[2])
192 args = fancyopts.fancyopts(args, i[1], cmdoptions, i[2])
186
193
@@ -192,6 +199,8 b' def dispatch(args):'
192
199
193 try:
200 try:
194 d()
201 d()
202 except SignalInterrupt:
203 u.warn("killed!\n")
195 except KeyboardInterrupt:
204 except KeyboardInterrupt:
196 u.warn("interrupted!\n")
205 u.warn("interrupted!\n")
197 except TypeError, inst:
206 except TypeError, inst:
General Comments 0
You need to be logged in to leave comments. Login now