# HG changeset patch # User Oleg Oshmyan # Date 1302279891 -10800 # Node ID f0b63838f407bb26cd60674f59692a6249fb6777 # Parent 5462291b66d57630886ad65afd461310b6567b1f Fixed a crash due to SIGCHLD interrupting validator output pipe reads diff -r 5462291b66d5 -r f0b63838f407 testcases.py --- 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():] diff -r 5462291b66d5 -r f0b63838f407 unix.py --- 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):