Files
clang-p2996/llvm/test/tools/llvm-symbolizer/Inputs/flush-output.py
Tobias Hieta b71edfaa4e [NFC][Py Reformat] Reformat python files in llvm
This is the first commit in a series that will reformat
all the python files in the LLVM repository.

Reformatting is done with `black`.

See more information here:

https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style

Reviewed By: jhenderson, JDevlieghere, MatzeB

Differential Revision: https://reviews.llvm.org/D150545
2023-05-17 10:48:52 +02:00

28 lines
639 B
Python

from __future__ import print_function
import os
import subprocess
import sys
import threading
def kill_subprocess(process):
process.kill()
os._exit(1)
# Pass -f=none and --output-style=GNU to get only one line of output per input.
cmd = subprocess.Popen(
[sys.argv[1], "--obj=" + sys.argv[2], "-f=none", "--output-style=GNU"],
stdout=subprocess.PIPE,
stdin=subprocess.PIPE,
)
watchdog = threading.Timer(20, kill_subprocess, args=[cmd])
watchdog.start()
cmd.stdin.write(b"0\n")
cmd.stdin.flush()
print(cmd.stdout.readline())
cmd.stdin.write(b"bad\n")
cmd.stdin.flush()
print(cmd.stdout.readline())
watchdog.cancel()