0

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
NewNet
  • 5
  • 3
  • https://stackoverflow.com/questions/4789837/how-to-terminate-a-python-subprocess-launched-with-shell-true Check this out first – geekay Feb 25 '23 at 14:10

0 Answers0