1## Show that SIGINT and similar signals don't cause crash messages to be 2## reported. 3# RUN: %python %s wrapper llvm-symbolizer 2> %t.err 4# RUN: count 0 < %t.err 5 6import os 7import signal 8import subprocess 9import sys 10import time 11 12def run_symbolizer(): 13 proc = subprocess.Popen([sys.argv[2]], stdout=subprocess.PIPE, stdin=subprocess.PIPE) 14 # Write then read some output to ensure the process has started fully. 15 proc.stdin.write(b'foo\n') 16 proc.stdin.flush() 17 proc.stdout.readline() 18 # Windows handles signals differently. 19 if os.name == 'nt': 20 os.kill(0, signal.CTRL_BREAK_EVENT) 21 else: 22 proc.send_signal(signal.SIGINT) 23 24# On Windows, this function spawns the subprocess in its own (hidden) console, 25# so that signals do not interfere with the calling test. This isn't necessary 26# on other systems. 27def run_wrapper(): 28 args = [sys.executable, __file__, 'symbolizer'] + sys.argv[2:] 29 if os.name == 'nt': 30 startupinfo = subprocess.STARTUPINFO() 31 startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW 32 proc = subprocess.Popen(args, 33 stderr=sys.stderr, 34 startupinfo=startupinfo, 35 creationflags=subprocess.CREATE_NEW_CONSOLE) 36 else: 37 proc = subprocess.Popen(args, 38 stderr=subprocess.PIPE) 39 40if sys.argv[1] == 'wrapper': 41 run_wrapper() 42else: 43 run_symbolizer() 44