[rtsan] Add fork/execve interceptors (#117198)
[llvm-project.git] / llvm / test / tools / llvm-symbolizer / Inputs / flush-output.py
blobc8e0b959c7da7a54794795acbfb163fe58f9d9dc
1 from __future__ import print_function
2 import os
3 import subprocess
4 import sys
5 import threading
8 def kill_subprocess(process):
9 process.kill()
10 os._exit(1)
13 # Pass -f=none and --output-style=GNU to get only one line of output per input.
14 cmd = subprocess.Popen(
15 [sys.argv[1], "--obj=" + sys.argv[2], "-f=none", "--output-style=GNU"],
16 stdout=subprocess.PIPE,
17 stdin=subprocess.PIPE,
19 watchdog = threading.Timer(20, kill_subprocess, args=[cmd])
20 watchdog.start()
21 cmd.stdin.write(b"0\n")
22 cmd.stdin.flush()
23 print(cmd.stdout.readline())
24 cmd.stdin.write(b"bad\n")
25 cmd.stdin.flush()
26 print(cmd.stdout.readline())
27 watchdog.cancel()