Mercurial > ~astiob > upreckon > hgweb
changeset 112:f0b63838f407 2.00
Fixed a crash due to SIGCHLD interrupting validator output pipe reads
author | Oleg Oshmyan <chortos@inbox.lv> |
---|---|
date | Fri, 08 Apr 2011 19:24:51 +0300 |
parents | 5462291b66d5 |
children | 3295bac0a7e6 |
files | testcases.py unix.py |
diffstat | 2 files changed, 14 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/testcases.py Fri Apr 08 19:22:19 2011 +0300 +++ b/testcases.py Fri Apr 08 19:24:51 2011 +0300 @@ -29,6 +29,11 @@ else: clock = time.time +class DummySignalIgnorer(object): + def __enter__(self): pass + def __exit__(self, exc_type, exc_value, traceback): pass +signal_ignorer = DummySignalIgnorer() + try: from win32 import * except Exception: @@ -274,7 +279,8 @@ case.process = Popen(case.validator, stdin=devnull, stdout=PIPE, stderr=STDOUT, universal_newlines=True, bufsize=-1) except OSError: raise CannotStartValidator(sys.exc_info()[1]) - comment = case.process.communicate()[0].strip() + with signal_ignorer: + comment = case.process.communicate()[0].strip() match = re.match(r'(?i)(ok|(?:correct|wrong)(?:(?:\s|_)*answer)?)(?:$|\s+|[.,!:]+\s*)', comment) if match: comment = comment[match.end():]
--- a/unix.py Fri Apr 08 19:22:19 2011 +0300 +++ b/unix.py Fri Apr 08 19:24:51 2011 +0300 @@ -112,6 +112,13 @@ except Exception: pass signal(SIGCHLD, bury_child) + class SignalIgnorer(object): + def __enter__(self): + signal(SIGCHLD, SIG_DFL) + def __exit__(self, exc_type, exc_value, traceback): + signal(SIGCHLD, bury_child) + signal_ignorer = SignalIgnorer() + __all__ += 'signal_ignorer', # If you want this to work portably, don't set any stdio argument to PIPE def call(*args, **kwargs):