comparison hgext/chgserver.py @ 29428:247ea0dfdb94

chgserver: do not ignore SIGPIPE if pager is used We rely on SIGPIPE to exit when the pager exits. And Python ignores SIGPIPE by default. Explicitly set SIGPIPE handler to SIG_DFL (terminate) just like pager.py.
author Jun Wu <quark@fb.com>
date Fri, 24 Jun 2016 17:06:41 +0100
parents 0d83ad967bf8
children 33770d2b6cf9
comparison
equal deleted inserted replaced
29427:33a6b750b5b9 29428:247ea0dfdb94
46 import hashlib 46 import hashlib
47 import inspect 47 import inspect
48 import os 48 import os
49 import random 49 import random
50 import re 50 import re
51 import signal
51 import struct 52 import struct
52 import sys 53 import sys
53 import threading 54 import threading
54 import time 55 import time
55 import traceback 56 import traceback
496 self.cresult.write('\0') 497 self.cresult.write('\0')
497 return 498 return
498 499
499 pagercmd = _setuppagercmd(self.ui, options, cmd) 500 pagercmd = _setuppagercmd(self.ui, options, cmd)
500 if pagercmd: 501 if pagercmd:
502 # Python's SIGPIPE is SIG_IGN by default. change to SIG_DFL so
503 # we can exit if the pipe to the pager is closed
504 if util.safehasattr(signal, 'SIGPIPE') and \
505 signal.getsignal(signal.SIGPIPE) == signal.SIG_IGN:
506 signal.signal(signal.SIGPIPE, signal.SIG_DFL)
501 self.cresult.write(pagercmd) 507 self.cresult.write(pagercmd)
502 else: 508 else:
503 self.cresult.write('\0') 509 self.cresult.write('\0')
504 510
505 def setenv(self): 511 def setenv(self):