I have following code which should run the binary
and terminate after 5 second and log the stdout which generated by the binary.
But the below code not logging any data to log.txt.
with open("log.txt", "w") as output:
try:
process = subprocess.run(["./binary", "2000", "0"], stdout=output,timeout=5)
if out.returncode != 0:
return False
except (subprocess.TimeoutExpired, UnicodeDecodeError) as e:
return False